Skip to content

Commit ba8b995

Browse files
committed
display thread in coro
1 parent dc7a167 commit ba8b995

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

py3/async/async_wget.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
#!/usr/bin/env python3
22
# -*- coding: utf-8 -*-
33

4+
import threading
45
import asyncio
56

67
@asyncio.coroutine
78
def wget(host):
89
print('wget %s...' % host)
10+
print('current thread: %s' % threading.current_thread())
911
connect = asyncio.open_connection(host, 80)
1012
reader, writer = yield from connect
1113
header = 'GET / HTTP/1.0\r\nHost: %s\r\n\r\n' % host
@@ -24,3 +26,4 @@ def wget(host):
2426
for task in tasks:
2527
loop.run_until_complete(task)
2628
loop.close()
29+
print('main thread: %s' % threading.current_thread())

0 commit comments

Comments
 (0)