mirror of
https://github.com/1j01/textual-paint.git
synced 2024-11-05 01:40:59 +03:00
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:
parent
cf39357641
commit
c2ee9ef2df
@ -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:
|
||||||
|
Loading…
Reference in New Issue
Block a user