Python watchdog: How to handle the watched directory being deleted?
56 views
Skip to first unread message
Jeffrey DeLeo
unread,
Dec 8, 2015, 1:31:19 PM12/8/15
Reply to author
Sign in to reply to author
Forward
Sign in to forward
Delete
You do not have permission to delete messages in this group
Copy link
Report message
Show original message
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to watchdog-python
I am happily using the watchdog package, specifically PollingObserver,
to watch directories for file events. It works great - until the
directory I am watching is deleted. What then happens is the code that
is polling the directory calls stat() on a non-existent
directory, and raises an exception. What is the best way to handle
this? I don't see how I can catch this exception as it's in a separate
thread.
I wonder if it would make sense for DirectorySnapshot to be None if the directory does not (or no longer) exists?