ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?
rosuav at gmail.com
Thu Sep 25 18:04:40 CEST 2014
On Fri, Sep 26, 2014 at 1:40 AM, Ian Kelly <ian.g.kelly at gmail.com> wrote:
> Fair enough. In the simple example above, I see no harm in simply
> moving the add_done_callback call outside (after) the "with self.lock"
> block altogether. I can imagine more complex examples where the call
> is further down the stack and harder to isolate from the lock,
> although I would argue that's probably a code smell.
I'd definitely call it code smell. What happens with this?
The lock's possibly released before the callback happens, or possibly
not, but either way, the code *looks* as if it's all happening inside
the "with lock" block. Recipe for confusion IMO.
More information about the Python-list