| 1 |
import eventlet |
| 2 |
eventlet.monkey_patch() |
| 3 |
|
| 4 |
from eventlet.patcher import original |
| 5 |
from eventlet.asyncio import spawn_for_awaitable |
| 6 |
|
| 7 |
import asyncio |
| 8 |
|
| 9 |
|
| 10 |
def in_thread(): |
| 11 |
time = original("time") |
| 12 |
time.sleep(0.001) |
| 13 |
return 3 + 4 |
| 14 |
|
| 15 |
|
| 16 |
async def go(): |
| 17 |
return await asyncio.gather( |
| 18 |
asyncio.to_thread(in_thread), |
| 19 |
asyncio.to_thread(in_thread), |
| 20 |
asyncio.to_thread(in_thread), |
| 21 |
) |
| 22 |
|
| 23 |
|
| 24 |
if __name__ == "__main__": |
| 25 |
assert spawn_for_awaitable(go()).wait() == [7, 7, 7] |
| 26 |
print("pass") |