Skip to content

Commit 7a097ec

Browse files
committed
Add async decorator example
1 parent 5589a0e commit 7a097ec

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

examples/async_decorator.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import asyncio
2+
3+
from memory_profiler import profile
4+
5+
6+
@profile
7+
@asyncio.coroutine
8+
def foo():
9+
a = [1] * (10 ** 6)
10+
b = [2] * (2 * 10 ** 7)
11+
yield from asyncio.sleep(1)
12+
del b
13+
return a
14+
15+
16+
if __name__ == "__main__":
17+
loop = asyncio.get_event_loop()
18+
loop.run_until_complete(foo())

0 commit comments

Comments
 (0)