[issue33786] @asynccontextmanager doesn't work well with async generators

2018-06-06 Thread Valentin Lavrinenko


Valentin Lavrinenko  added the comment:

Sorry, `async with ctx()` in main() is not needed.

--

___
Python tracker 
<https://bugs.python.org/issue33786>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue33786] @asynccontextmanager doesn't work well with async generators

2018-06-06 Thread Valentin Lavrinenko


New submission from Valentin Lavrinenko :

```
@asynccontextmanager
async def ctx():
yield


async def gen():
async with ctx():
yield 'hello'
yield 'world'


async def main():
async with ctx():
async for value in gen():
print(value)
raise RuntimeError()
```

Running main() leads to `RuntimeError: generator didn't stop after throw()`. 
This happens because async gernerator's `.athrow()` method doesn't re-throw 
`GeneratorExit` exception; probably, this is wrong.

--
components: asyncio
messages: 318853
nosy: Valentin Lavrinenko, asvetlov, yselivanov
priority: normal
severity: normal
status: open
title: @asynccontextmanager doesn't work well with async generators
versions: Python 3.7

___
Python tracker 
<https://bugs.python.org/issue33786>
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com