From 2a2f871886c6ad05adb5dd849d056998621e763b Mon Sep 17 00:00:00 2001 From: Luke Murphy Date: Sat, 3 Oct 2020 11:39:20 +0200 Subject: [PATCH] Handle async writes properly --- etherpump/commands/pull.py | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/etherpump/commands/pull.py b/etherpump/commands/pull.py index 56ddc4a..907cd17 100644 --- a/etherpump/commands/pull.py +++ b/etherpump/commands/pull.py @@ -407,10 +407,8 @@ async def handle_pad(args, padid, data, info, session): links=links, ) async with await trio.open_file(ver["path"], "w") as f: - print( - ET.tostring(doc, method="html", encoding="unicode"), - file=f, - ) + output = ET.tostring(doc, method="html", encoding="unicode") + await f.write(output) except TypeError: ver["message"] = html["message"] @@ -432,9 +430,8 @@ async def handle_pad(args, padid, data, info, session): doc, indent=True, title=padid, scripts=args.script, links=links, ) async with await trio.open_file(ver["path"], "w") as f: - print( - ET.tostring(doc, method="html", encoding="unicode"), file=f, - ) + output = ET.tostring(doc, method="html", encoding="unicode") + await f.write(output) # output meta if args.all or args.meta: