ATLAS Offline Software
Loading...
Searching...
No Matches
dqu_subprocess.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3def _local_apply_core(func, args, q):
4 import os
5 try:
6 q.put(func(*args))
7 except Exception as e:
8 q.put(e)
9 os._exit(1)
10
11def apply(func, args):
12 from queue import Empty
13 from multiprocessing import Process
14 from multiprocessing.managers import SyncManager
15
16 with SyncManager() as m:
17 q = m.Queue()
18 p = Process(target=_local_apply_core, args=(func, args, q))
19 p.start()
20 p.join()
21 print('Manager socket is', m.address)
22 try:
23 rv = q.get(False)
24 except Empty:
25 raise RuntimeError('daughter died while trying to execute %s%s' % (func.__name__, args))
26 if isinstance(rv, BaseException):
27 if isinstance(rv, SystemExit):
28 print('SystemExit raised by daughter; ignoring')
29 return None
30 else:
31 raise rv
32 return rv
void print(char *figname, TCanvas *c1)
_local_apply_core(func, args, q)