21 lines
598 B
Markdown
21 lines
598 B
Markdown
```python
|
|
import asyncio
|
|
def _run_once(loop):
|
|
loop._process_events(loop._selector.select(0))
|
|
if (ready := loop._ready) and (handle := ready.popleft())._cancelled is False:
|
|
task = (tasks := asyncio.tasks._current_tasks).pop(loop, None)
|
|
handle._run(); tasks[loop] = task
|
|
(loop := asyncio.get_event_loop()).__class__._run_once = _run_once
|
|
loop.__class__._check_running = lambda _: 0; asyncio.run = loop.run_until_complete
|
|
|
|
async def hello():
|
|
print('hello')
|
|
async def world():
|
|
print('world')
|
|
asyncio.run(world())
|
|
asyncio.run(hello())
|
|
"""
|
|
hello
|
|
world
|
|
"""
|
|
``` |