Use CriticalSection to prevent deadlocks on dequeue

Interesting. I'd be very surprised if `queue.Queue.get_nowait` ever deadlocked. (assuming it's always the built-in `queue.Queue` and not some gevent-patched version or `multiprocessing.Queue`)