Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
when_file_changed handlers may be lost #44
Comments
|
More and more I think that re-testing the queue when a state is removed is a mistake. It was put in there to try to guard against the case of a handler taking some action that negated the state but then a subsequent handler taking action as if the state were still set and that causing an error. However, there's just as much of an issue if two handlers have Additionally, it doesn't seem like the framework can both guard against that case and ensure that all handlers get their chance to run when their conditions are met, and the latter seems like the more important goal. Finally, if that sort of co-dependence exists between handlers, it seems likely to be a design flaw and even so the handler could always manually check the state again with |
|
This seems like a tricky case. I think retesting the queue is the correct thing to do. Consider the following use-case:
Restarting a stopped service is not something you want to do. However, the current way Consider |
stub42 commentedJan 6, 2016
This may be the general case of Issue #25
Several handlers decorated by when_file_changed may be scheduled for an iteration. If any handler removes state, handlers that should no longer be triggered are removed. Unfortunately, this includes all the pending when_file_changed handlers, as the file checksums now match and the check is now False.
In this example, the bounce_foo handler will not run if the do_something handler is invoked first.
Resetting the hashes would be tricky, so maybe the best approach is to have the when_file_changed decorator set some internal state so that the check always returns true until the handler as been run and the state reverted.