bugfix
This commit is contained in:
parent
f053753fdb
commit
4921a5c62c
@ -3,8 +3,7 @@ import random
|
|||||||
import asyncio
|
import asyncio
|
||||||
import inspect
|
import inspect
|
||||||
import concurrent
|
import concurrent
|
||||||
from functools import wraps
|
from functools import wraps, partial
|
||||||
from functools import wraps
|
|
||||||
|
|
||||||
def schedule_once(seconds, coro, *args, **kw):
|
def schedule_once(seconds, coro, *args, **kw):
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
@ -82,7 +81,7 @@ class AsyncWorker:
|
|||||||
return stdout, stderr
|
return stdout, stderr
|
||||||
|
|
||||||
if __name__ == '__main__':
|
if __name__ == '__main__':
|
||||||
def hello(cnt,greeting):
|
def hello(cnt,greeting='how are you'):
|
||||||
t = random.randint(1,10)
|
t = random.randint(1,10)
|
||||||
print(cnt,'will sleep ',t,'seconds')
|
print(cnt,'will sleep ',t,'seconds')
|
||||||
time.sleep(t)
|
time.sleep(t)
|
||||||
@ -97,7 +96,7 @@ if __name__ == '__main__':
|
|||||||
async def run():
|
async def run():
|
||||||
w = AsyncWorker()
|
w = AsyncWorker()
|
||||||
f = awaitify(hello)
|
f = awaitify(hello)
|
||||||
g = [ asyncio.create_task(w(f,i,'hello world')) for i in range(100) ]
|
g = [ asyncio.create_task(w(f,i,greeting='hello world')) for i in range(100) ]
|
||||||
await asyncio.wait(g)
|
await asyncio.wait(g)
|
||||||
print('aaaaaaaaaaaaaaaaaaa')
|
print('aaaaaaaaaaaaaaaaaaa')
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user