-
-
Notifications
You must be signed in to change notification settings - Fork 701
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
OSError: [Errno9] Bad file descriptor #805
Comments
This also causes a test failure:
|
I removed my second from watchdog.observers import Observer
from watchdog.events import FileSystemEventHandler
def start():
class Mod_handler(FileSystemEventHandler):
def on_modified(self, event):
if(event.src_path == "/database.json"):
print("Execute your logic here!")
print("on_modified", event.src_path)
event_handler = Mod_handler()
observer = Observer()
observer.schedule(event_handler, path='/', recursive=False)
observer.start() It works now |
Hey all! I'm hitting this issue a lot in my environment. I'm using watchdog to place watches on a directory structure with ~10k folders and ~60M files. The structure is a dumping ground for rsync to move gzip files from our lab equipment for long term storage. I've noticed that rsync creates a temporary file while the transfer is in progress, then either moves or renames the file to the original name. Ex. my_data_file.tar.gz becomes my_data_file.tar.gz.A5B6 on the remote system during transfer, then changed back to my_data_file.tar.gz when the transfer is complete. With several hundred of these events happening every second I see this 'Bad File Descriptor' exception within a few minutes and it kills the Observers I have created. I'm sharing here to maybe help someone reproduce the issue, or at least give a real world use case that would exacerbate the issue described here. |
I don't see any reference here to import sys
import time
import logging
from watchdog.observers import Observer
from watchdog.events import LoggingEventHandler
if __name__ == "__main__":
logging.basicConfig(level=logging.INFO,
format='%(asctime)s - %(message)s',
datefmt='%Y-%m-%d %H:%M:%S')
path = sys.argv[1] if len(sys.argv) > 1 else '.'
event_handler = LoggingEventHandler()
observer = Observer()
observer.schedule(event_handler, path, recursive=True)
observer.start()
try:
while True:
time.sleep(1)
finally:
observer.stop()
observer.join() |
While stopping and joining seems like a reasonable thing to be necessary, it alone wasn't sufficient to avoid the bad file descriptor exception. It looks like there's a race condition between shutting down the thread(s) and closing the file descriptor. Even a 10us sleep makes the thread shutdown usually lose. altendky#1 if someone already familiar with the code base has time to add a test and fix, that'd be just awesome! Otherwise, I'll see what I can manage later. |
Fixed with #895. |
I have no idea why this is happening. Looking at the traceback, it looks like a package error.
watch.py
bot.py
The text was updated successfully, but these errors were encountered: