monitoring the filesystem for changes

momobear wgwigw at gmail.com
Sun Jun 3 21:02:33 EDT 2007


> You could use the ReadDirectoryChangesW in overlapped
> mode. I've never tried it, so I don't know how
> robust it would be. Why is it a problem to have
> "multiple programs" running? And is that simply
> multiple threads, or multiple processes?
I used overlapped in my program, it runs about 1 week, seems no
problems now.
FILE_LIST_DIRECTORY = 0x0001
hDir = None

def __init__(self, directory):
	self.hDir = win32file.CreateFile (
  			directory,
  			self.FILE_LIST_DIRECTORY,
  			win32con.FILE_SHARE_READ | win32con.FILE_SHARE_WRITE,
  			None,
  			win32con.OPEN_EXISTING,
  			win32con.FILE_FLAG_BACKUP_SEMANTICS|
win32con.FILE_FLAG_OVERLAPPED,
  			None
			)
but I didn't try use multiple program do the same action. I think only
one thread to do directory monitor is enough. other thread and process
can communicate with it use thread or process communication.

Wang Wei





More information about the Python-list mailing list