Cezary Wagner <cezary.wag...@gmail.com> added the comment:

Use case - detection of changes in open files is very important - log scanning 
- synchronization ...

I think that first of all it is need good unit test to detect this problem 
(rare edge case - probably it is missed because hard to imagine that it can not 
work when file is open - I will miss this I think).

It should work like this.

First program is writing file under Windows and second program (unit test) is 
running os.scandir() if repeated os.scandir() detect changes it is O.K. (same 
like in Linux).

To make it simpler it can be unit test in one program.

1. Open test file in test directory.
2. os.scandir() in test directory.
3. Some writes to test file (f.write() with and without flush, ... - to be 
defined what is sufficient to test).
4. os.scandir() in test directory - if change detected it O.K.
5. f.close()

I do not know Windows API now but I think we can detect id directory is changed 
between scans or we can detect if file is open (it is rare situation - rare 
edge case) in 90% all files will be closed.

So if all files is closed current os.scandir() maybe is good (not I do not 
understand implementation to evaluate it correclty) and when one of file or 
more there is need another implementation which will detect modification.

If you think I missed something please comment. You are welcome.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue41106>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to