Skip to content

Commit 9dd40f0

Browse files
authored
Add join_threads() (#10086)
* Update __init__.py Signed-off-by: Glenn Jocher <[email protected]> * Update __init__.py Signed-off-by: Glenn Jocher <[email protected]> * Update __init__.py Signed-off-by: Glenn Jocher <[email protected]> Signed-off-by: Glenn Jocher <[email protected]>
1 parent ea73386 commit 9dd40f0

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

utils/__init__.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,16 @@ def wrapper(*args, **kwargs):
3737
return wrapper
3838

3939

40+
def join_threads(verbose=False):
41+
# Join all daemon threads, i.e. atexit.register(lambda: join_threads())
42+
main_thread = threading.current_thread()
43+
for t in threading.enumerate():
44+
if t is not main_thread:
45+
if verbose:
46+
print(f'Joining thread {t.name}')
47+
t.join()
48+
49+
4050
def notebook_init(verbose=True):
4151
# Check system software and hardware
4252
print('Checking setup...')

0 commit comments

Comments
 (0)