On 7 October 2016 at 16:42, Nathaniel Smith
For folks who prefer the gevent API, is it really easier to port libraries to asyncio than to port them to gevent?
It's definitely *not* easier, as gevent lets you suspend execution inside arbitrary CPython magic method calls. That's why you can still use SQL Alchemy's ORM layer with gevent - greenlet can swap the stack even with the extra C call frames on there. If you're running in vanilla CPython (or recent non-Windows versions of PyPy2), on a relatively mainstream architecture like x86_64 or ARM, then gevent/greenlet will be fine as an applications synchronous/asyncrhonous bridge. However, if you're running in a context that embeds CPython inside a larger application (e.g. mod_wsgi inside Apache), then gevent's assumptions about how the C thread states are managed may be wrong, and hence you may be in for some "interesting" debugging sessions. The same goes for any library that implements callbacks that end up executing a greenlet switch when they weren't expecting it (e.g. while holding a threading lock - that will protect you from other OS threads, but not from other greenlets in the same thread) Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia