Skip to content

Instantly share code, notes, and snippets.

View timothymugayi's full-sized avatar
🎯
Focusing

Timothy Mugayi timothymugayi

🎯
Focusing
View GitHub Profile
@tappoz
tappoz / python-multiprocessing-with-global-timeout.md
Last active October 2, 2022 04:00
Python multiprocessing with global timeout

How to join processes with timeout

The process.join(NUM_SECONDS) does not fit, because the normal for loop to join all the processes waits NUM_SECONDS for each process before joining it.

We want a global amount of NUM_SECONDS to be timed out on to kill (terminate) all the outstanding processes that are still alive after NUM_SECONDS elapsed (i.e. not yet been joined already).

The following code snippet has been heavily inspired by: