MCPcopy Create free account
hub / github.com/FreeformRobotics/OTS / _set_SIGCHLD_handler

Function _set_SIGCHLD_handler

lib/utils/data/dataloader.py:163–185  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

161
162
163def _set_SIGCHLD_handler():
164 # Windows doesn't support SIGCHLD handler
165 if sys.platform == 'win32':
166 return
167 # can't set signal in child threads
168 if not isinstance(threading.current_thread(), threading._MainThread):
169 return
170 global _SIGCHLD_handler_set
171 if _SIGCHLD_handler_set:
172 return
173 previous_handler = signal.getsignal(signal.SIGCHLD)
174 if not callable(previous_handler):
175 previous_handler = None
176
177 def handler(signum, frame):
178 # This following call uses `waitid` with WNOHANG from C side. Therefore,
179 # Python can still get and update the process status successfully.
180 _error_if_any_worker_fails()
181 if previous_handler is not None:
182 previous_handler(signum, frame)
183
184 signal.signal(signal.SIGCHLD, handler)
185 _SIGCHLD_handler_set = True
186
187
188class DataLoaderIter(object):

Callers 1

__init__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected