Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-18 Thread Ben Darnell
On Mon, Dec 18, 2017 at 8:37 PM Yury Selivanov 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 re

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-18 Thread Ben Darnell
On Sun, Dec 17, 2017 at 2:49 PM Yury Selivanov wrote: > > One caveat based on Tornado's experience with stack_context: There are > times > > when the automatic propagation of contexts won't do the right thing (for > > example, a database client with a connection pool may end up hanging on > to >

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-18 Thread Yury Selivanov
On Mon, Dec 18, 2017 at 6:00 PM, Ivan Levkivskyi wrote: > On 13 December 2017 at 22:35, Yury Selivanov > wrote: >> >> [..] >> >> A new standard library module ``contextvars`` is added >> > >> > Why not add this to contextlib instead of adding a new module? IIRC >> > this was discussed relative t

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-18 Thread Yury Selivanov
> 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

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-18 Thread Ivan Levkivskyi
On 13 December 2017 at 22:35, Yury Selivanov wrote: > [..] > >> A new standard library module ``contextvars`` is added > > > > Why not add this to contextlib instead of adding a new module? IIRC > > this was discussed relative to PEP 550, but I don't remember the > > reason. Regardless, it woul

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-17 Thread Yury Selivanov
Hi Ben, On Sun, Dec 17, 2017 at 10:38 AM, Ben Darnell wrote: > On Tue, Dec 12, 2017 at 12:34 PM Yury Selivanov > wrote: >> >> Hi, >> >> This is a new proposal to implement context storage in Python. >> >> It's a successor of PEP 550 and builds on some of its API ideas and >> datastructures. Con

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-17 Thread Ben Darnell
On Tue, Dec 12, 2017 at 12:34 PM Yury Selivanov wrote: > Hi, > > This is a new proposal to implement context storage in Python. > > It's a successor of PEP 550 and builds on some of its API ideas and > datastructures. Contrary to PEP 550 though, this proposal only focuses > on adding new APIs an

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-13 Thread Yury Selivanov
Hi Eric, Thanks for a detailed review! On Wed, Dec 13, 2017 at 3:59 PM, Eric Snow wrote: > Overall, I like this PEP. It's definitely easier to follow > conceptually than PEP 550. Thanks for taking the time to re-think the > idea. I have a few comments in-line below. > > -eric > > On Tue, Dec

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-13 Thread Eric Snow
On Tue, Dec 12, 2017 at 4:49 PM, Victor Stinner wrote: >> The ``Token`` API exists to make the current proposal forward >> compatible with :pep:`550`, in case there is demand to support >> context variables in generators and asynchronous generators in the >> future. > > Cool. I like the idea of st

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-13 Thread Eric Snow
Overall, I like this PEP. It's definitely easier to follow conceptually than PEP 550. Thanks for taking the time to re-think the idea. I have a few comments in-line below. -eric On Tue, Dec 12, 2017 at 10:33 AM, Yury Selivanov wrote: > This is a new proposal to implement context storage in Py

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-13 Thread Victor Stinner
Hi Dima, 2017-12-13 7:39 GMT+01:00 Dima Tisnek : > get()/set(value)/delete() methods: Python provides syntax sugar for > these, let's use it. > (dict: d["k"]/d["k] = value/del d["k"]; attrs: obj.k/obj.k = value/del > obj.k; inheriting threading.Local) I was trapped by Context which is described a

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-13 Thread Nathaniel Smith
On Tue, Dec 12, 2017 at 10:39 PM, Dima Tisnek wrote: > My 2c: > TL;DR PEP specifies implementation in some detail, but doesn't show > how proposed change can or should be used. > > > > get()/set(value)/delete() methods: Python provides syntax sugar for > these, let's use it. > (dict: d["k"]/d["k]

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-12 Thread Dima Tisnek
My 2c: TL;DR PEP specifies implementation in some detail, but doesn't show how proposed change can or should be used. get()/set(value)/delete() methods: Python provides syntax sugar for these, let's use it. (dict: d["k"]/d["k] = value/del d["k"]; attrs: obj.k/obj.k = value/del obj.k; inheriting

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-12 Thread Yury Selivanov
On Tue, Dec 12, 2017 at 10:36 PM, Guido van Rossum wrote: > Some more feedback: > >> This proposal builds directly upon concepts originally introduced >> in :pep:`550`. > > The phrase "builds upon" typically implies that the other resource must be > read and understood first. I don't think that we

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-12 Thread Guido van Rossum
Some more feedback: > This proposal builds directly upon concepts originally introduced > in :pep:`550`. The phrase "builds upon" typically implies that the other resource must be read and understood first. I don't think that we should require PEP 550 for understanding of PEP 567. Maybe "This pro

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-12 Thread Yury Selivanov
On Tue, Dec 12, 2017 at 9:55 PM, Guido van Rossum wrote: > On Tue, Dec 12, 2017 at 5:35 PM, Yury Selivanov > wrote: >> >> On Tue, Dec 12, 2017 at 6:49 PM, Victor Stinner >> wrote: >> > I like the overall idea and I prefer this PEP over PEP 550 since it's >> > shorter and easier to read :-) >> >

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-12 Thread Guido van Rossum
On Tue, Dec 12, 2017 at 5:35 PM, Yury Selivanov wrote: > On Tue, Dec 12, 2017 at 6:49 PM, Victor Stinner > wrote: > > I like the overall idea and I prefer this PEP over PEP 550 since it's > > shorter and easier to read :-) > > > > Question: Is there an API to list all context variables? > > Cont

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-12 Thread Yury Selivanov
Hi Victor, On Tue, Dec 12, 2017 at 6:49 PM, Victor Stinner wrote: > Hi Yury, > > I like the overall idea and I prefer this PEP over PEP 550 since it's > shorter and easier to read :-) > > Question: Is there an API to list all context variables? Context implements abc.Mapping, so 'get_context().k

Re: [Python-Dev] PEP 567 -- Context Variables

2017-12-12 Thread Victor Stinner
Hi Yury, I like the overall idea and I prefer this PEP over PEP 550 since it's shorter and easier to read :-) Question: Is there an API to list all context variables? Would it be possible to have a very summary of the changes in the PEP? I propose: """ * Added contextvars module with ContextVar

[Python-Dev] PEP 567 -- Context Variables

2017-12-12 Thread Yury Selivanov
Hi, This is a new proposal to implement context storage in Python. It's a successor of PEP 550 and builds on some of its API ideas and datastructures. Contrary to PEP 550 though, this proposal only focuses on adding new APIs and implementing support for it in asyncio. There are no changes to th