Start process(es) with SIGINT ignored. Args: proc: (mp.Process or list) Note: The signal mask is only applied when called from main thread.
(proc)
| 215 | |
| 216 | |
| 217 | def start_proc_mask_signal(proc): |
| 218 | """ |
| 219 | Start process(es) with SIGINT ignored. |
| 220 | |
| 221 | Args: |
| 222 | proc: (mp.Process or list) |
| 223 | |
| 224 | Note: |
| 225 | The signal mask is only applied when called from main thread. |
| 226 | """ |
| 227 | if not isinstance(proc, list): |
| 228 | proc = [proc] |
| 229 | |
| 230 | with mask_sigint(): |
| 231 | for p in proc: |
| 232 | if isinstance(p, mp.Process): |
| 233 | if sys.version_info < (3, 4) or mp.get_start_method() == 'fork': |
| 234 | log_once(""" |
| 235 | Starting a process with 'fork' method is efficient but not safe and may cause deadlock or crash. |
| 236 | Use 'forkserver' or 'spawn' method instead if you run into such issues. |
| 237 | See https://docs.python.org/3/library/multiprocessing.html#contexts-and-start-methods on how to set them. |
| 238 | """.replace("\n", ""), |
| 239 | 'warn') # noqa |
| 240 | p.start() |
| 241 | |
| 242 | |
| 243 | def subproc_call(cmd, timeout=None): |
no test coverage detected
searching dependent graphs…