Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78332
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.swapon.de!eternal-september.org!feeder.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail |
|---|---|
| From | Marko Rauhamaa <marko@pacujo.net> |
| Newsgroups | comp.lang.python |
| Subject | Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? |
| Date | Thu, 25 Sep 2014 12:46:55 +0300 |
| Organization | A noiseless patient Spider |
| Lines | 28 |
| Message-ID | <871tr06nhs.fsf@elektro.pacujo.net> (permalink) |
| References | <e2f400e6-359e-4070-a822-d734e85e6a75@googlegroups.com> <mailman.14345.1411627213.18130.python-list@python.org> |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset=us-ascii |
| Injection-Info | mx05.eternal-september.org; posting-host="ff5cf27ef3d5b31f034d3b72bdc27a41"; logging-data="5979"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18AVK3J+xuCdcyX4sw5C6cS" |
| User-Agent | Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux) |
| Cancel-Lock | sha1:N2cpEQB/XosK7d9uNbesmrNI6zw= sha1:BPjlNVhu8muqtI4h0bLT9ES9u68= |
| Xref | csiph.com comp.lang.python:78332 |
Show key headers only | View raw
Ian Kelly <ian.g.kelly@gmail.com>:
> The documentation for Future.add_done_callback says: "If the future
> has already completed or been cancelled, fn will be called
> immediately."
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.
Example (pseudocode):
def callback(self):
with self.lock:
...
def xyz(self, f):
with self.lock:
...
f.add_done_callback(self.callback)
The code will deadlock if the callback is invoked immediately.
Marko
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? Praveen Gollakota <pgollakota@gmail.com> - 2014-09-24 07:44 -0700
Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? dieter <dieter@handshake.de> - 2014-09-25 08:14 +0200
Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? Ian Kelly <ian.g.kelly@gmail.com> - 2014-09-25 00:39 -0600
Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? Marko Rauhamaa <marko@pacujo.net> - 2014-09-25 12:46 +0300
Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? Ian Kelly <ian.g.kelly@gmail.com> - 2014-09-25 08:16 -0600
Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? Marko Rauhamaa <marko@pacujo.net> - 2014-09-25 17:47 +0300
Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? Ian Kelly <ian.g.kelly@gmail.com> - 2014-09-25 09:40 -0600
Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function? Chris Angelico <rosuav@gmail.com> - 2014-09-26 02:04 +1000
csiph-web