Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78325

Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?

Path csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!xlned.com!feeder5.xlned.com!newsfeed.xs4all.nl!newsfeed4a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.003
X-Spam-Evidence '*H*': 0.99; '*S*': 0.00; 'subject:same': 0.07; 'callback': 0.09; 'executed': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'thread': 0.14; 'function"': 0.16; 'function?': 0.16; 'received:80.91.229.3': 0.16; 'received:dip0.t-ipconnect.de': 0.16; 'received:plane.gmane.org': 0.16; 'received:t-ipconnect.de': 0.16; 'subject:run': 0.16; 'code.': 0.18; 'looked': 0.18; 'header:User-Agent:1': 0.23; 'question': 0.24; 'source': 0.25; 'skip:" 20': 0.27; 'header:X -Complaints-To:1': 0.27; 'writes:': 0.31; 'run': 0.32; 'quite': 0.32; 'subject:the': 0.34; 'could': 0.34; 'done': 0.36; 'charset :us-ascii': 0.36; 'subject:?': 0.36; 'should': 0.36; 'easiest': 0.38; 'to:addr:python-list': 0.38; 'sure': 0.39; 'to:addr:python.org': 0.39; 'received:org': 0.40; 'tell': 0.60; 'details.': 0.61; 'received:217': 0.63; 'subject:skip:T 10': 0.68; 'guaranteed': 0.75
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From dieter <dieter@handshake.de>
Subject Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?
Date Thu, 25 Sep 2014 08:14:26 +0200
References <e2f400e6-359e-4070-a822-d734e85e6a75@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=us-ascii
X-Gmane-NNTP-Posting-Host pd9e0b82c.dip0.t-ipconnect.de
User-Agent Gnus/5.1008 (Gnus v5.10.8) XEmacs/21.4.22 (linux)
Cancel-Lock sha1:Q+9TvwTvAd7QdC1zx5u1/qiym8Q=
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.14343.1411625683.18130.python-list@python.org> (permalink)
Lines 17
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1411625683 news.xs4all.nl 2945 [2001:888:2000:d::a6]:51551
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:78325

Show key headers only | View raw


Praveen Gollakota <pgollakota@gmail.com> writes:
> In the ThreadPoolExecutor (TPE), is the callback always guaranteed to run in the same thread as the submitted function?

To answer question of this type (yourself), you may look
at the relevant source code.

I am quite sure that the "submitted function" will be executed
in one of the threads from the thread pool.

I have not looked at the "ThreadPoolExecutor" code. The easiest thing
would be to run the callback in the same thread as the submitted function.
However, it could facilitate use of the "ThreadPoolExecutor"
(less locking) when the synchronisation were done inside
the "ThreadPoolExecutor" and the callbacks were executed in a single
thread (likely the one which has set up the "ThreadPoolExecutor").
A look at the source should tell the details.

Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


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