[Python-ideas] async objects

Cory Benfield cory at lukasa.co.uk
Wed Oct 12 13:08:58 EDT 2016


> On 7 Oct 2016, at 16:18, Nick Coghlan <ncoghlan at gmail.com> wrote:
> 
> 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)

I can speak to this. It’s been my professional experience with gevent that choosing to obtain concurrency by using gevent as opposed to explicit async was a trade-off: we replaced a large amount of drudge work in writing a codebase with async/await pervasively throughout it with a smaller amount of dramatically (10x to 100x times) more intellectually challenging debugging work when unstated assumptions regarding thread-safety and concurrent access were violated.

For many developers these trade offs are sensible and reasonable, but we should all remember that there are costs and advantages of most kinds of runtime model. I’m happy to have a language that lets me do all of these things than one that chooses one for me and says “that ought to be good enough for everyone”.

Cory


More information about the Python-ideas mailing list