On Thu, Apr 24, 2014 at 8:24 AM, Saúl Ibarra Corretgé <[email protected]>wrote:

> On 04/24/2014 05:17 PM, Jack Murray wrote:
> > Apologies for digging up old thread.
> >
> > I notice that in python 3.4, asyncio spawns a new thread in this
> > situation:
> >
> > print("Threading, before:",threading.active_count()) self._server =
> > yield from self._loop.create_server(lambda: self, *self._address)
> > print("Threading, after:",threading.active_count())
> >
> > That is called in a coroutine running in self._loop. I am confused
> > about this behaviour.. is there a way to get the accept loop for
> > the server running in the same thread? What I want is to ensure
> > that any coroutine touching this object is being run in the same
> > thread, including all connections and their handlers.
> >
>
> I suspect the created thread is just a ThreadPoolExecutor thread used
> to do getaddrinfo. The asyncio event loop will run in a single thread.
>

Yes, that's what's happening. Check out the code for getaddrinfo() in the
asyncio source code.

(We should revive UTSL -- "Use The Source, Luke!" :-)

-- 
--Guido van Rossum (python.org/~guido)

Reply via email to