queueand the producer threads have been generalized to place success or failure callback on the queue in response to exits and exceptions moreoverthe actions that run in producer threads receive progress status function whichwhen calledsimply adds progress indicator callback to the queue to be dispatched by the main thread we can use thisfor exampleto show progress in the gui during network downloads example - pp \gui\tools\threadtools py ""################################################################################system-wide thread interface utilities for guis implements single thread callback queue and checker timer loop shared by all the windows in programworker threads queue their exit and progress actions to be run in the main threadthis doesn' block the gui it just spawns operations and manages and dispatches exits and progressworker threads can overlap freely with the main threadand with other workers using queue of callback functions and arguments is more useful than simple data queue if there can be many kinds of threads running at the same time each kind may have different implied exit actions because gui api is not completely thread-safeinstead of calling gui update callbacks directly after thread main actionplace them on shared queueto be run from timer loop in the main threadnot child threadthis also makes gui update points less random and unpredictablerequires threads to be split into main actionexit actionsand progress action assumes threaded action raises an exception on failureand has 'progresscallback argument if it supports progress updatesalso assumes callbacks are either short-lived or update as they runand that queue will contain callback functions (or other callablesfor use in gui app requires widget in order to schedule and catch 'afterevent loop callbacksto use this model in non-gui contextscould use simple thread timer instead ################################################################################""run even if no threads tryimport _thread as thread except importerrorimport _dummy_thread as thread in standard lib now raise importerror to run with gui blocking if threads not available same interfaceno threads shared cross-process queue named in shared global scopelives in shared object memory import queuesys threadqueue queue queue(maxsize= infinite size ################################################################################in main thread periodically check thread completions queuerun implied gui actions on queue in this main gui threadone consumer (gui)and multiple producers (loaddelsend) simple list may suffice toolist append and guisthreadsand queues