Python
- 4 ответа
- 0 вопросов
1
Вклад в тег
import asyncio
class Document:
async def save(self, name):
await asyncio.sleep(1)
print(f'Document "{name}" has saved')
async def first():
name = "test_document.doc"
print("Run first function")
await second(name)
async def second(name):
await Document().save(name)
asyncio.run(first())
async def first():
print("Run first function")
await asyncio.gather(
second('doc_1'),
second('doc_2'),
second('doc_3'),
)