python
import eliot
from eliot import start_action, to_file, Message
to_file(open("logs.txt", "w"))
async def perform_async_task(name):
with start_action(action_type="perform_async_task"):
Message.log(message_type="task_started", task_name=name)
await asyncio.sleep(1)
Message.log(message_type="task_completed", task_name=name)
async def main():
with start_action(action_type="main"):
tasks = [
perform_async_task("task1"),
perform_async_task("task2")
]
await asyncio.gather(*tasks)
if __name__ == "__main__":
asyncio.run(main())