[issue28699] Imap from ThreadPool behaves unexpectedly

Xiang Zhang report at bugs.python.org
Thu Nov 17 13:01:51 EST 2016


Xiang Zhang added the comment:

> Your patch looks to be introducing a number of changes to the structure of the data being passed around between threads and even monitored/indirectly shared across processes. 

That's why I say even myself don't like it. To solve an edge case some long introduced codes have to been changed. Sigh.

> Under relevant conditions, check both _items and _unsorted (not only _items) before declaring that we truly have all results in.

I think you mean your patch. But how does it solve the reentrant problem? Yeah, actually it's not reentrant. If the problematic job is not the first job with id 0, then the exception won't be set.

With your patch, repeatedly execute print(list(pool.imap(str, gen()))). Only the first time there is an exception.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28699>
_______________________________________


More information about the Python-bugs-list mailing list