[Python-Dev] PEP 567 -- Context Variables

Ben Darnell ben at bendarnell.com
Mon Dec 18 21:37:56 EST 2017


On Mon, Dec 18, 2017 at 8:37 PM Yury Selivanov <yselivanov.ml at gmail.com>
wrote:

> > 3. The connection pool has a queue, and creates a task for each
> connection to serve requests from that queue. Naively, each task could
> inherit the context of the request that caused it to be created, but the
> task would outlive the request and go on to serve other requests. The
> connection pool would need to specifically suppress the caller's context
> when creating its worker tasks.
>
> I haven't used this pattern myself, but it looks like a good case for
> adding a keyword-only 'context' rgument to `loop.create_task()`.  This
> way the pool can capture the context when some API method is called
> and pass it down to the queue along with the request.  The queue task
> can then run connection code in that context.
>
>
Yes, that would be useful.

-Ben
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-dev/attachments/20171219/1f82c849/attachment.html>


More information about the Python-Dev mailing list