[Python-ideas] Thread-safe generators

Greg Ewing greg.ewing at canterbury.ac.nz
Fri Apr 14 18:42:35 EDT 2017


Serhiy Storchaka wrote:
> but should not 
> affect performance since locking is used only when you faced with a 
> generator running in other thread.

I don't think that's true, because the first thread to use a
generator has to lock it as well. And even if there is only
one thread in existence when __next__ is called, another one
could be created before it finishes and try to use the
generator.

-- 
Greg


More information about the Python-ideas mailing list