Skip to content

Commit e43d78b

Browse files
authored
Merge pull request #307 from d-ryzhikov/coroutine-return-value
fix: return result from wrapped coroutine function
2 parents f9497b9 + 13405c5 commit e43d78b

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

memory_profiler.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -710,7 +710,8 @@ def wrap_function(self, func):
710710
@coroutine
711711
def f(*args, **kwargs):
712712
with self._count_ctxmgr():
713-
yield from func(*args, **kwargs)
713+
res = yield from func(*args, **kwargs)
714+
return res
714715
else:
715716
def f(*args, **kwds):
716717
with self._count_ctxmgr():

test/test_async.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ def my_func():
1010
b = [2] * (2 * 10 ** 7)
1111
yield from asyncio.sleep(1e-2)
1212
del b
13+
return 42
1314

1415

1516
if __name__ == '__main__':
1617
loop = asyncio.get_event_loop()
17-
loop.run_until_complete(my_func())
18+
res = loop.run_until_complete(my_func())
19+
assert res == 42

0 commit comments

Comments
 (0)