From 1c77302cf6f2c7165b3afbc3d7601c641dae02ed Mon Sep 17 00:00:00 2001 From: jay817 Date: Mon, 25 Nov 2024 14:02:56 -0500 Subject: [PATCH] Add nest-asyncio/README.md --- nest-asyncio/README.md | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 nest-asyncio/README.md diff --git a/nest-asyncio/README.md b/nest-asyncio/README.md new file mode 100644 index 0000000..567f561 --- /dev/null +++ b/nest-asyncio/README.md @@ -0,0 +1,19 @@ +```python +'' +import asyncio +(loop := asyncio.get_event_loop()).__class__._check_running = lambda _: None +def _run_once(self): + self._process_events(self._selector.select(0)) + if (ready := self._ready) and not (handle := ready.popleft())._cancelled: + task = (tasks := asyncio.tasks._current_tasks).pop(self, None) + handle._run() + tasks[self] = task +loop.__class__._run_once = _run_once +asyncio.run = loop.run_until_complete +'' +async def hello(): + async def world(): print('hello') + asyncio.run(world()) or print('world') +asyncio.run(hello()) # OK +'' +``` \ No newline at end of file