"Marko Rauhamaa" wrote in message news:871t8orhua@elektro.pacujo.net...
"Frank Millman" :
> I have never been able to get Ctrl+C to work properly on Windows, so I
> use a separate thread that simply waits for Enter.
Now you are leaving my realm of expertise, as I haven't programmed for
wi
"Frank Millman" :
> I have never been able to get Ctrl+C to work properly on Windows, so I
> use a separate thread that simply waits for Enter.
Now you are leaving my realm of expertise, as I haven't programmed for
windows since Windows 1.0. Mixing threads, asyncio, input() and Windows
seems like
"Marko Rauhamaa" wrote in message news:87r3gpq7mi@elektro.pacujo.net...
I can't see your complete program, but here's mine, and it seems to be
working
Thanks, Marko, I really appreciate your assistance.
I wanted to show you my complete program, but as it is quite long I
distilled it
"Frank Millman" :
> Alas, I spoke too soon.
>
> [...]
>
> If I press Ctrl+C, I get a traceback from the threading module -
>
>line 1288, in _shutdown
>t.join()
>line 1054, in join
>self._wait_for_tstate_lock()
>line 1070, in _wait_for_tstate_lock
> KeyboardInterrupt
>
>
"Frank Millman" wrote in message news:n96kjr$mvl$1...@ger.gmane.org...
"Marko Rauhamaa" wrote in message
news:8737t5shhp@elektro.pacujo.net...
> Actually, cancellation is specially supported in asyncio ( https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel>)
> so this
"Marko Rauhamaa" wrote in message news:8737t5shhp@elektro.pacujo.net...
>
Actually, cancellation is specially supported in asyncio (https://docs.python.org/3/library/asyncio-task.html#asyncio.Task.cancel>)
so this should do:
async def background_task():
while True:
a
Marko Rauhamaa :
> async def background_task(cancel_event):
> while True:
> await asyncio.wait(
> perform_task, cancel_event.wait,
> return_when=asyncio.FIRST_COMPETED)
> if cancel_event_is_set()
> break
>
"Frank Millman" :
> "Marko Rauhamaa" wrote in message news:87lh6ys052@elektro.pacujo.net...
>> You should
>>
>>await asyncio.wait(..., return_when=asyncio.FIRST_COMPLETED)
>>
>> to deal with multiple alternative stimuli.
>>
>
> Thanks, Marko, that works very well.
>
> [...]
>
> Now I just
"Marko Rauhamaa" wrote in message news:87lh6ys052@elektro.pacujo.net...
"Frank Millman" :
> When shutting the main program down, I want to stop the task, but I
> cannot figure out how to stop it cleanly - i.e. wait until it has
> finished the current task and possibly performed some cleanu
"Frank Millman" :
> When shutting the main program down, I want to stop the task, but I
> cannot figure out how to stop it cleanly - i.e. wait until it has
> finished the current task and possibly performed some cleanup, before
> continuing.
Here (and really, only here) is where asyncio shows its
10 matches
Mail list logo