python
from eliot import start_action, to_file
to_file(open("logs.txt", "w"))
with start_action(action_type="main"):
try:
perform_async_task()
except Exception as e:
start_action(action_type="error").add_exceptions(e)
def perform_async_task():
with start_action(action_type="task"):
d = make_async_request()
d.addCallback(handle_response)
def make_async_request():
return async_request()
def handle_response(response):
with start_action(action_type="response"):
print(response)