Fix process sometimes hangs issue by improving exit and exception handlers, unregistering signal handling in child processes except for the BackgroundMonitor

This commit is contained in:
allegroai
2023-12-13 16:41:21 +02:00
parent 07dcbcac08
commit 8cb7d14abb
5 changed files with 265 additions and 180 deletions

View File

@@ -355,6 +355,21 @@ def stdout_print(*args, **kwargs):
sys.stdout.write(line)
def debug_print(*args, **kwargs):
"""
Print directly to stdout, with process and timestamp from last print call
Example: [pid=123, t=0.003] message here
"""
global tic
tic = globals().get('tic', time.time())
stdout_print(
"\033[1;33m[pid={}, t={:.04f}] ".format(os.getpid(), time.time()-tic)
+ str(args[0] if len(args) == 1 else ("" if not args else args)) + "\033[0m"
, **kwargs
)
tic = time.time()
if __name__ == '__main__':
# from clearml import Task
# task = Task.init(project_name="examples", task_name="trace test")