[issue14632] Race condition in WatchedFileHandler leads to unhandled exception

JohnM report at bugs.python.org
Sun Apr 22 20:41:57 CEST 2012


JohnM <phlogistonjohn at asynchrono.us> added the comment:

Thank you both for looking at this. I've added an updated version of the patch that incorporates the last two suggestions that Charles-François made.

I agree that this test may not be appropriate for the python test suite, due to the length and non-determinism of the test. I don't know what the suite's policy on monkey patching stdlib in the tests is, but monkey patching either os.path.exists or os.stat to remove the file at the appropriate time could be one way to make the test fast and deterministic. Seems a bit dirty to me though. :-)
 
I am up for adding some kind of test to the suite for the WatchedFileHandler, though.

I'm pretty ambivalent about keeping the whole stat structure around, since the samestat method is just a wrapper around what the emit function is already doing, and we'd be keeping more memory (although a small amount) around. I doubt we'd want to look at the timestamps because they could legitimately change in ways this check doesn't care about.

----------
Added file: http://bugs.python.org/file25305/watchedfilehandler.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue14632>
_______________________________________


More information about the Python-bugs-list mailing list