Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python 2.7 and windows 7 #85

Closed
AndreaCrotti opened this issue Dec 5, 2011 · 3 comments
Closed

Python 2.7 and windows 7 #85

AndreaCrotti opened this issue Dec 5, 2011 · 3 comments

Comments

@AndreaCrotti
Copy link

Since I had some problems with python2.5, I tried also python 2.7 and now I get a different error:
(I guess something wrong with ctypes and the windows dlls, but I can't tell much more than that...)

C-c C-cException in thread Thread-2:
Traceback (most recent call last):
File "c:\Python27\lib\threading.py", line 552, in __bootstrap_inner
self.run()
File "c:\Python27\lib\site-packages\watchdog-0.5.4-py2.7.egg\watchdog\observers\api.py", line 192, in run
self.queue_events(self.timeout)
File "c:\Python27\lib\site-packages\watchdog-0.5.4-py2.7.egg\watchdog\observers\read_directory_changes.py", line 80, in queue_events
self.watch.is_recursive)
File "c:\Python27\lib\site-packages\watchdog-0.5.4-py2.7.egg\watchdog\observers\winapi_common.py", line 130, in read_directory_changes
None)
File "c:\Python27\lib\site-packages\watchdog-0.5.4-py2.7.egg\watchdog\observers\winapi.py", line 103, in _errcheck_bool
raise ctypes.WinError()
WindowsError: [Error 1] Incorrect function.

@LongHairedHacker
Copy link

Hi,
I'm sorry for bumping this two year old issue, but just ran into the exact same problem with Windows 10, python2.7 and watchdog 0.8.3

It can be reproduced by the following piece of code:

import time

from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler

class Handler(FileSystemEventHandler):
    def on_any_event(self, event):
        print "File changed: %s" % event.src_path

if __name__ == '__main__':
    event_handler = Handler()
    observer = Observer()
    observer.schedule(event_handler, '.', recursive=True)
    observer.start()

    try:
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        observer.stop()
    observer.join()

The resulting exception looks like this:

Exception in thread Thread-2:
Traceback (most recent call last):
  File "c:\python27\Lib\threading.py", line 801, in __bootstrap_inner
    self.run()
  File "C:\Users\IEUser\Envs\xtrude\lib\site-packages\watchdog\observers\api.py", line 146, in run
    self.queue_events(self.timeout)
  File "C:\Users\IEUser\Envs\xtrude\lib\site-packages\watchdog\observers\read_directory_changes.py", line 77, in queue_events
    winapi_events = read_events(self._handle, self.watch.is_recursive)
  File "C:\Users\IEUser\Envs\xtrude\lib\site-packages\watchdog\observers\winapi.py", line 347, in read_events
    buf, nbytes = read_directory_changes(handle, recursive)
  File "C:\Users\IEUser\Envs\xtrude\lib\site-packages\watchdog\observers\winapi.py", line 307, in read_directory_changes
    raise e
WindowsError: [Error 1] Incorrect function.

Please tell me if you need any further information.

@LongHairedHacker
Copy link

Did some digging into the windows api on my own and sure enough I was able to identify the problem.

Looking up the return values of ReadDirectoryChangesW I found the following:

If the network redirector or the target file system does not support this operation, the function fails with ERROR_INVALID_FUNCTION.
https://msdn.microsoft.com/en-us/library/windows/desktop/aa365465(v=vs.85).aspx

I've been working on a network share.
Copying the files I need to watch to a local filesystem fixed it for me.

I'll leave this here in case anyone else finds this issue while googling the error message.

@bendtherules
Copy link

bendtherules commented Jun 13, 2017

This helped me just today. Maybe we should raise a custom error with a little bit more detailed message of why this happened (Or maybe just a link to this issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants