Greplin/greplin-twisted-utils — pull request #2 by kevinclark (2012-08-16 07:41:55+00:00)
Title: Stale context

Currently, when we do a deferred read or write, we restore the context that was in place when the deferred event was created. But after the event happens we also restore the parent context. It seems that this restoration sometimes happens *after* other events have fired and it ends up overwriting a context incorrectly. My solution is to just never restore context afterwards - we really only care about the one that needs to be installed when the function gets called. The Context object's exit function handles the rest.

I'm able to get these tests to fail by putting the deleted lines back into _doReadOrWrite, so I can show a fix there. I removed the equivalent lines from wrappedFn on a hunch, but I haven't gotten the error to reproduce there - it could use a test case if you know how to trigger it.