Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 4:33 PM, Antoine Pitrou wrote: > > Le 29/08/2017 à 22:20, Yury Selivanov a écrit : >> >> 2) >> >>gvar = new_context_var() >>var = new_context_var() >> >>async def bar(): >># EC = [current_thread_LC_copy, Task_foo_LC_copy, Task_wait_for_LC] > > Ah, thanks

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Antoine Pitrou
Le 29/08/2017 à 22:20, Yury Selivanov a écrit : > > 2) > >gvar = new_context_var() >var = new_context_var() > >async def bar(): ># EC = [current_thread_LC_copy, Task_foo_LC_copy, Task_wait_for_LC] Ah, thanks!... That explains things, though I don't expect most users to spo

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 4:10 PM, Antoine Pitrou wrote: [..] >> "await bar()" and "await wait_for(bar())" are actually quite >> different. Let me illustrate with an example: >> >> b1 = bar() >> # bar() is not running yet >> await b1 >> >> b2 = wait_for(bar()) >> # bar() was wra

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Nathaniel Smith
On Tue, Aug 29, 2017 at 12:59 PM, Yury Selivanov wrote: > b2 = wait_for(bar()) > # bar() was wrapped into a Task and is being running right now > await b2 Ah not quite. wait_for is itself implemented as a coroutine, so it doesn't spawn off bar() into its own task until you await b

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Antoine Pitrou
Le 29/08/2017 à 21:59, Yury Selivanov a écrit : > > This absolutely needs to be fixed, and the only way (that I know) it > can be fixed is to revert the "every coroutine has its own LC" > statement (going back to the semantics coroutines had in PEP 550 v2 > and v3). I completely agree with this.

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Nathaniel Smith
On Tue, Aug 29, 2017 at 12:32 PM, Antoine Pitrou wrote: > > > Le 29/08/2017 à 21:18, Yury Selivanov a écrit : >> On Tue, Aug 29, 2017 at 2:40 PM, Antoine Pitrou wrote: >>> On Mon, 28 Aug 2017 17:24:29 -0400 >>> Yury Selivanov wrote: Long story short, I think we need to rollback our last dec

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 3:32 PM, Antoine Pitrou wrote: > > > Le 29/08/2017 à 21:18, Yury Selivanov a écrit : >> On Tue, Aug 29, 2017 at 2:40 PM, Antoine Pitrou wrote: >>> On Mon, 28 Aug 2017 17:24:29 -0400 >>> Yury Selivanov wrote: Long story short, I think we need to rollback our last deci

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Antoine Pitrou
Le 29/08/2017 à 21:18, Yury Selivanov a écrit : > On Tue, Aug 29, 2017 at 2:40 PM, Antoine Pitrou wrote: >> On Mon, 28 Aug 2017 17:24:29 -0400 >> Yury Selivanov wrote: >>> Long story short, I think we need to rollback our last decision to >>> prohibit context propagation up the call stack in co

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Yury Selivanov
On Tue, Aug 29, 2017 at 2:40 PM, Antoine Pitrou wrote: > On Mon, 28 Aug 2017 17:24:29 -0400 > Yury Selivanov wrote: >> Long story short, I think we need to rollback our last decision to >> prohibit context propagation up the call stack in coroutines. In PEP >> 550 v3 and earlier, the following s

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Antoine Pitrou
On Mon, 28 Aug 2017 17:24:29 -0400 Yury Selivanov wrote: > Long story short, I think we need to rollback our last decision to > prohibit context propagation up the call stack in coroutines. In PEP > 550 v3 and earlier, the following snippet would work just fine: > >var = new_context_var() >

Re: [Python-Dev] PEP 550 v4: coroutine policy

2017-08-29 Thread Nick Coghlan
On 29 August 2017 at 07:24, Yury Selivanov wrote: > This means that PEP 550 will have a caveat for async code: don't rely > on context propagation up the call stack, unless you are writing > __aenter__ and __aexit__ that are guaranteed to be called without > being wrapped into a Task. I'm not sur

[Python-Dev] PEP 550 v4: coroutine policy

2017-08-28 Thread Yury Selivanov
Long story short, I think we need to rollback our last decision to prohibit context propagation up the call stack in coroutines. In PEP 550 v3 and earlier, the following snippet would work just fine: var = new_context_var() async def bar(): var.set(42) async def foo(): aw