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?

From dieter <dieter@handshake.de>
Subject Re: ThreadPoolExecutor - callback guaranteed to run in same thread as the submitted function?
Date 2014-09-25 08:14 +0200
References <e2f400e6-359e-4070-a822-d734e85e6a75@googlegroups.com>
Newsgroups comp.lang.python
Message-ID <mailman.14343.1411625683.18130.python-list@python.org> (permalink)

Show all headers | 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