Question about asyncio and blocking operations

Frank Millman frank at chagford.com
Fri Jan 29 00:23:21 EST 2016


"Ian Kelly"  wrote in message 
news:CALwzidn6NfT_O0cfHw1itWja81+MW3scHuEcADVCen3ix6z73w at mail.gmail.com...
>
> As I commented in my previous message, asyncio.Queue is not
> thread-safe, so it's very important that the put calls here be done on
> the event loop thread using event_loop.call_soon_threadsafe. This
> could be the cause of the strange behavior you're seeing in getting
> the results.
>

Using call_soon_threadsafe makes all the difference. The rows are now 
retrieved instantly.

I have read the other messages, and I can see that there are some clever 
ideas there. However, having found something that seems to work and that I 
feel comfortable with, I plan to run with this for the time being.

Thanks to all for the very stimulating discussion.

Frank





More information about the Python-list mailing list