Update asyncio/README.md

This commit is contained in:
2024-10-04 01:55:27 -04:00
parent 8eb570361b
commit 86322c0daf

View File

@@ -1,6 +1,6 @@
## nest_asyncio ## nest_asyncio
```python ```python
'Sync' 'sync'
def Sync(): def Sync():
import asyncio, functools, importlib.util as U import asyncio, functools, importlib.util as U
U.find_spec('nest_asyncio') or os.system('pip install -q nest_asyncio') U.find_spec('nest_asyncio') or os.system('pip install -q nest_asyncio')
@@ -21,9 +21,12 @@ async def Page():
if callable(method := getattr(page, attr)) and not attr.startswith('_'): if callable(method := getattr(page, attr)) and not attr.startswith('_'):
setattr(page, attr, sync(method)) setattr(page, attr, sync(method))
return page return page
page = Page()
page.goto('http://example.com') 'main'
print(page.title()) # Example Domain if __name__ == '__main__':
page = Page()
page.goto('http://example.com')
print(page.title()) # Example Domain
``` ```
## threading ## threading