(self, parent_sentinel=None)
| 295 | ## |
| 296 | |
| 297 | def _bootstrap(self, parent_sentinel=None): |
| 298 | from . import util, context |
| 299 | global _current_process, _parent_process, _process_counter, _children |
| 300 | |
| 301 | try: |
| 302 | if self._start_method is not None: |
| 303 | context._force_start_method(self._start_method) |
| 304 | _process_counter = itertools.count(1) |
| 305 | _children = set() |
| 306 | util._close_stdin() |
| 307 | old_process = _current_process |
| 308 | _current_process = self |
| 309 | _parent_process = _ParentProcess( |
| 310 | self._parent_name, self._parent_pid, parent_sentinel) |
| 311 | if threading._HAVE_THREAD_NATIVE_ID: |
| 312 | threading.main_thread()._set_native_id() |
| 313 | try: |
| 314 | self._after_fork() |
| 315 | finally: |
| 316 | # delay finalization of the old process object until after |
| 317 | # _run_after_forkers() is executed |
| 318 | del old_process |
| 319 | util.info('child process calling self.run()') |
| 320 | self.run() |
| 321 | exitcode = 0 |
| 322 | except SystemExit as e: |
| 323 | if e.code is None: |
| 324 | exitcode = 0 |
| 325 | elif isinstance(e.code, int): |
| 326 | exitcode = e.code |
| 327 | else: |
| 328 | sys.stderr.write(str(e.code) + '\n') |
| 329 | exitcode = 1 |
| 330 | except: |
| 331 | exitcode = 1 |
| 332 | import traceback |
| 333 | sys.stderr.write('Process %s:\n' % self.name) |
| 334 | traceback.print_exc() |
| 335 | finally: |
| 336 | threading._shutdown() |
| 337 | util.info('process exiting with exitcode %d' % exitcode) |
| 338 | util._flush_std_streams() |
| 339 | |
| 340 | return exitcode |
| 341 | |
| 342 | @staticmethod |
| 343 | def _after_fork(): |
no test coverage detected