-
Notifications
You must be signed in to change notification settings - Fork 5.5k
Description
There is an occasional race condition in the tests when the IOLoop is shut down and a ThreadedResolver is used. The error message is "IOError: close() called during concurrent operation on the same file object."
The problem is that in the worker thread, add_callback releases the lock before writing to the waker pipe. If the IOLoop happens to wake up for other reasons it could run the callback and proceed to the end of the test (which closes the reactor) before the worker thread writes to the waker pipe (There is probably something else going on since I see this happening more often than I would expect from the timing involved).
Possible fixes include shutting down the threadpool after every test (i.e. undoing be52944 and slowing down the test suite), or holding the callback_lock while writing to the waker pipe (increasing contention on the callback_lock but reducing redundant writes to the pipe)