terminate a program gracefully from a thread

Terry Reedy tjreedy at udel.edu
Sat Mar 22 21:48:02 CET 2014


On 3/22/2014 8:40 AM, Jabba Laci wrote:

> I have a script (see below) that I want to terminate after X seconds.
> The main loop of the program is waiting for user input.
> The program enters the main loop and I try to shut down the program
> after X seconds from a thread but I can't figure out how to do it. The
> program should also do some cleanup before termination, so the shut
> down must be graceful.

Although you have gotten comments specific to your problem, this type of 
thing should be easy (in just one thread) with asyncio (new in 3.4, 
backport on PyPI).

-- 
Terry Jan Reedy




More information about the Python-list mailing list