Simplify: don't need a Task!

This still handles errors, unlike a million things I tried before,
and can still work and exit successfully.
This commit is contained in:
Isaiah Odhner 2023-05-04 14:28:02 -04:00
parent cf39357641
commit c2ee9ef2df

View File

@ -3392,18 +3392,9 @@ if args.recode_samples:
await app.save() await app.save()
print(f"Saved {filename}") print(f"Saved {filename}")
# have to wait for the app to be initialized # have to wait for the app to be initialized
def once_running() -> None: async def once_running() -> None:
task = asyncio.create_task(recode_samples()) await recode_samples()
app.background_tasks.add(task) app.exit()
def done_callback(future: asyncio.Future[None]) -> None:
exception = future.exception()
app.background_tasks.discard(task)
if exception:
def raise_exception() -> None:
raise exception
app.call_later(raise_exception)
app.exit()
task.add_done_callback(done_callback)
app.call_later(once_running) app.call_later(once_running)
if args.clear_screen: if args.clear_screen: