ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?
marko at pacujo.net
Thu Sep 25 11:46:55 CEST 2014
Ian Kelly <ian.g.kelly at gmail.com>:
> The documentation for Future.add_done_callback says: "If the future
> has already completed or been cancelled, fn will be called
That sounds really bad.
There should be a guarantee that the callback is not called from the
same thread before returning from Future.add_done_callback. Otherwise,
the caller may have a really difficult time handling preemption and
avoiding deadlocks at the same time.
def xyz(self, f):
The code will deadlock if the callback is invoked immediately.
More information about the Python-list