Update nest-asyncio/README.md
This commit is contained in:
@@ -1,19 +1,17 @@
|
|||||||
```python
|
```python
|
||||||
import asyncio
|
import asyncio
|
||||||
(loop := asyncio.get_event_loop()).__class__._check_running = lambda _: None
|
|
||||||
def _run_once(loop):
|
def _run_once(loop):
|
||||||
loop._process_events(loop._selector.select(0))
|
loop._process_events(loop._selector.select(0))
|
||||||
if (ready := loop._ready) and not (handle := ready.popleft())._cancelled:
|
if (ready := loop._ready) and (handle := ready.popleft())._cancelled is False:
|
||||||
task = (tasks := asyncio.tasks._current_tasks).pop(loop, None)
|
task = (tasks := asyncio.tasks._current_tasks).pop(loop, None)
|
||||||
handle._run()
|
handle._run(); tasks[loop] = task
|
||||||
tasks[loop] = task
|
(loop := asyncio.get_event_loop()).__class__._run_once = _run_once
|
||||||
loop.__class__._run_once = _run_once
|
loop.__class__._check_running = lambda _: 0; asyncio.run = loop.run_until_complete
|
||||||
asyncio.run = loop.run_until_complete
|
|
||||||
|
|
||||||
|
|
||||||
async def hello():
|
async def hello():
|
||||||
print('hello')
|
print('hello')
|
||||||
async def world(): print('world')
|
async def world():
|
||||||
|
print('world')
|
||||||
asyncio.run(world())
|
asyncio.run(world())
|
||||||
asyncio.run(hello())
|
asyncio.run(hello())
|
||||||
"""
|
"""
|
||||||
|
|||||||
Reference in New Issue
Block a user