MCPcopy Index your code
hub / github.com/python/cpython / _exit_function

Function _exit_function

Lib/multiprocessing/util.py:391–431  ·  view source on GitHub ↗
(info=info, debug=debug, _run_finalizers=_run_finalizers,
                   active_children=process.active_children,
                   current_process=process.current_process)

Source from the content-addressed store, hash-verified

389_exiting = False
390
391def _exit_function(info=info, debug=debug, _run_finalizers=_run_finalizers,
392 active_children=process.active_children,
393 current_process=process.current_process):
394 # We hold on to references to functions in the arglist due to the
395 # situation described below, where this function is called after this
396 # module's globals are destroyed.
397
398 global _exiting
399
400 if not _exiting:
401 _exiting = True
402
403 info('process shutting down')
404 debug('running all "atexit" finalizers with priority >= 0')
405 _run_finalizers(0)
406
407 if current_process() is not None:
408 # We check if the current process is None here because if
409 # it's None, any call to ``active_children()`` will raise
410 # an AttributeError (active_children winds up trying to
411 # get attributes from util._current_process). One
412 # situation where this can happen is if someone has
413 # manipulated sys.modules, causing this module to be
414 # garbage collected. The destructor for the module type
415 # then replaces all values in the module dict with None.
416 # For instance, after setuptools runs a test it replaces
417 # sys.modules with a copy created earlier. See issues
418 # #9775 and #15881. Also related: #4106, #9205, and
419 # #9207.
420
421 for p in active_children():
422 if p.daemon:
423 info('calling terminate() for daemon %s', p.name)
424 p._popen.terminate()
425
426 for p in active_children():
427 info('calling join() for process %s', p.name)
428 p.join()
429
430 debug('running the remaining "atexit" finalizers')
431 _run_finalizers()
432
433atexit.register(_exit_function)
434

Callers

nothing calls this directly

Calls 7

_run_finalizersFunction · 0.85
current_processFunction · 0.85
infoFunction · 0.70
debugFunction · 0.70
active_childrenFunction · 0.70
terminateMethod · 0.45
joinMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…