If an app coordinated actions with wait(unique_token) calls, every unique_token would exist in the internal WaitPool for the lifetime of the app. This change makes sure to clean up the tokens and related empty sets when then are no longer needed.
There is a comment to this effect, but file descriptors can get reused. If a read event and write event were triggered for a fd and the read callback unregistered the fd (because the remote closed) and then attempted a reconnect and the fd was reused when registerd, the write callback was still getting invoked in the same iteration of event handling. However, the callback wasn't intended for a disconnected socket. The bug was observed when attempting to reconnect dropped SSL connections in a try/except block. It was causing the event hub to freeze up indefinitely. The event hub now tracks an ID for file descriptors and checks that the ID at the start of even processing for a fd is the same after doing read callback handling. If the ID changes the write callback is not invoked.
so that imports from "dns" don't grab from DNS.py itself on case-insensitive filesystems.
Normal ConnectionPools are able to be created at the module level, outside of any diesel Loop. This is a useful feature. However, if you specified a pool_max value when creating your ConnectionPool outside of a Loop, you'd get an exception. This fix changes the way the sentinel values are added to the remaining_conns Queue in the ConnectionPool constructor. It adds them without firing any diesel events.
Required a bugfix to the handle_events method. Callbacks that were getting appended to run_now were running after those that were added to reschedule. That was happening because run_now was gettinged extended with reschedule before handling events from the hub loop. Like the EPollEventHub, we now do multiple iterations over run_now during handle_events. The second pass runs any that were added during hub loop event handling. Last of all, the callbacks that were in reschedule are put into run_now for the next call.