You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The first time I save the watched file in LibreOffice, I see the event printed, but on subsequent prints, there is nothing until I send the KeyboardInterrupt. The terminal output is:
<FileModifiedEvent: event_type=modified, src_path='./test.docx', is_directory=False>
^CTraceback (most recent call last):
File "main.py", line 49, in main
time.sleep(1)
KeyboardInterrupt
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "main.py", line 61, in <module>
main()
File "main.py", line 51, in main
observer.stop()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/utils/__init__.py", line 81, in stop
self.on_thread_stop()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/observers/api.py", line 361, in on_thread_stop
self.unschedule_all()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/observers/api.py", line 357, in unschedule_all
self._clear_emitters()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/observers/api.py", line 231, in _clear_emitters
emitter.stop()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/utils/__init__.py", line 81, in stop
self.on_thread_stop()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/observers/inotify.py", line 121, in on_thread_stop
self._inotify.close()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/observers/inotify_buffer.py", line 50, in close
self.stop()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/utils/__init__.py", line 81, in stop
self.on_thread_stop()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/observers/inotify_buffer.py", line 46, in on_thread_stop
self._inotify.close()
File "/home/lsimons/.local/lib/python3.8/site-packages/watchdog/observers/inotify_c.py", line 277, in close
os.close(self._inotify_fd)
OSError: [Errno 9] Bad file descriptor
I've noticed that when LibreOffice saves, a bunch of temporary files are created. If I instead watch the home directory recursively (observer.schedule(event_handler, './', recursive=True)), I can see modified events on the edited file:
However, watching the entire directory recursively that a file is in and filtering for only the events I'm interested in doesn't feel like a good solution. Is this kind of behavior expected? I thought maybe LibreOffice was deleting and recreating test.docx rapidly during a save, but the FileModifiedEvent is modified rather than deletion and creation.
The text was updated successfully, but these errors were encountered:
When testing the example code with watchdog 2.0.1, the error is gone, but the event handler is still only called the first time the file is saved. Is this considered a new bug?
That's normal. The error is gone as expected but then the watcher is no more watching anything. You have to setup again the watcher because the watched file was deleted by LibreOffice. It may be easier to watch the parent folder instead of the file.
I'm using the following code based on the example:
The first time I save the watched file in LibreOffice, I see the event printed, but on subsequent prints, there is nothing until I send the
KeyboardInterrupt
. The terminal output is:I've noticed that when LibreOffice saves, a bunch of temporary files are created. If I instead watch the home directory recursively (
observer.schedule(event_handler, './', recursive=True)
), I can see modified events on the edited file:However, watching the entire directory recursively that a file is in and filtering for only the events I'm interested in doesn't feel like a good solution. Is this kind of behavior expected? I thought maybe LibreOffice was deleting and recreating
test.docx
rapidly during a save, but the FileModifiedEvent is modified rather than deletion and creation.The text was updated successfully, but these errors were encountered: