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
When I'm watching a directory for changes, and a new file gets created in it, subsequent appends to that file generate more Change.added events instead of Change.modified for a while, then eventually switch to generating Change.modified events. If the file is already existing before I start watching, it starts emitting Change.modified events straight away.
I'm running the example code provided below in one terminal, while I'm repeatedly running echo foo >> test.log in another, inside the watched directory. I can confirm that the appends happen as intended, with new lines getting added to the file.
This is a problem for my use case, because on Change.modified my logic will just read one line from the already-opened file, while on Change.added it will reopen the file and read all lines from the start (assuming the reason for the Change.added event was because the file was deleted and recreated by whatever process writes to that file). This means that for a while after the file gets created, every line added will result in all lines being reprocessed, resulting in the same lines being processed repeatedly.
Description
When I'm watching a directory for changes, and a new file gets created in it, subsequent appends to that file generate more
Change.added
events instead ofChange.modified
for a while, then eventually switch to generatingChange.modified
events. If the file is already existing before I start watching, it starts emittingChange.modified
events straight away.I'm running the example code provided below in one terminal, while I'm repeatedly running
echo foo >> test.log
in another, inside the watched directory. I can confirm that the appends happen as intended, with new lines getting added to the file.This is a problem for my use case, because on
Change.modified
my logic will just read one line from the already-opened file, while onChange.added
it will reopen the file and read all lines from the start (assuming the reason for theChange.added
event was because the file was deleted and recreated by whatever process writes to that file). This means that for a while after the file gets created, every line added will result in all lines being reprocessed, resulting in the same lines being processed repeatedly.Example Code
Watchfiles Output
Operating System & Architecture
macOS-14.4.1-arm64-arm-64bit
Darwin Kernel Version 23.4.0: Fri Mar 15 00:10:42 PDT 2024; root:xnu-10063.101.17~1/RELEASE_ARM64_T6000
Environment
No response
Python & Watchfiles Version
python: 3.11.9 (main, May 8 2024, 08:06:17) [Clang 15.0.0 (clang-1500.3.9.4)], watchfiles: 0.21.0
Rust & Cargo Version
No response
The text was updated successfully, but these errors were encountered: