mirror of
https://gitflic.ru/project/openide/openide.git
synced 2025-12-16 14:23:28 +07:00
Patch field '_ready' from asyncio event loop for internal coroutine. Patch `asyncio.new_event_loop()` Add wrapper 'PyDevCoro' for internal coroutine. Patch `asyncio.Task.__init__`, `asyncio.ensure_future` and `asyncio.call_soon`. Add tests for `asyncio.gather` function. Patch `asyncio.new_event_loop()`. IJ-CR-99158 GitOrigin-RevId: 881087716a84c8ebb5331de4e2829bf38f2090e2
26 lines
495 B
Python
26 lines
495 B
Python
import asyncio
|
|
|
|
|
|
async def foo(y):
|
|
return y + 1
|
|
|
|
|
|
async def factorial(name, number):
|
|
f = 1
|
|
for i in range(2, number + 1):
|
|
print(f"Task {name}: Compute factorial({number}), currently i={i}...")
|
|
await asyncio.sleep(1)
|
|
f *= i
|
|
print(f"Task {name}: factorial({number}) = {f}")
|
|
return f
|
|
|
|
|
|
async def main():
|
|
L = await asyncio.gather(
|
|
factorial("A", 2),
|
|
factorial("B", 3),
|
|
factorial("C", 4),
|
|
)
|
|
print(L)
|
|
|
|
asyncio.run(main()) |