jeffh/sniffer — pull request #13 by jojje (2013-08-01 14:43:57+00:00)
Title: pywin scanner fixes

Two fixes:

1. Changes were not detected when test or source files were updated.
The problem stemmed from two issues.

1. First the `is_valid_type` check prevented any processing of file change events discovered by the windows API, as the modified files would always be valid. So I negated the test which I believe is what you intended (exit the loop only when files are *invalid*).

2. Changes to files on my Win7 machine using UltraEdit or Vim only resulted in `Renamed from` events being reported. Thus the file events were never actioned on as that event type didn't exist in the list of expected `action`s.

2. User can't terminate (CTRL-C) sniffer from console.
The `ReadDirectoryChangesW` function is a blocking call and as it's called from the main thread it prevents sniffer from processing any signals the user might want to send, such as SIGINT/SIGQUIT.
To address that, I made the ReadDirectoryChangesW call run in its own thread, which solved *that* problem.
*And yes, I'm kind of surprised that this worked, as I had feared I'd have to resort to multiprocessing for the execution decoupling. Luckily it seems some bits of Python are running "parallel enough"*