2016-04-13 10:27:06 -04:00
|
|
|
# test simple async with execution
|
|
|
|
|
|
|
|
class AContext:
|
|
|
|
async def __aenter__(self):
|
|
|
|
print('enter')
|
|
|
|
async def __aexit__(self, exc_type, exc, tb):
|
2016-09-27 21:52:13 -04:00
|
|
|
print('exit', exc_type, exc)
|
2016-04-13 10:27:06 -04:00
|
|
|
|
|
|
|
async def f():
|
|
|
|
async with AContext():
|
|
|
|
print('body')
|
|
|
|
|
|
|
|
o = f()
|
|
|
|
try:
|
|
|
|
o.send(None)
|
|
|
|
except StopIteration:
|
|
|
|
print('finished')
|
2016-09-27 21:52:13 -04:00
|
|
|
|
|
|
|
async def g():
|
|
|
|
async with AContext():
|
|
|
|
raise ValueError('error')
|
|
|
|
|
|
|
|
o = g()
|
|
|
|
try:
|
|
|
|
o.send(None)
|
|
|
|
except ValueError:
|
|
|
|
print('ValueError')
|