Python Glossary Русский

Python 3.4+multiprocessingfunction

multiprocessing.get_all_start_methods()

start methods

Returns the list of start methods supported on this platform; the first one is the default. On Windows the list holds only 'spawn'.

Syntax

multiprocessing.get_all_start_methods()

Unlike get_start_method(), it fixes nothing, so it is safe for checks such as "is forkserver available". The order changed between versions: on Linux up to 3.13 'fork' comes first, since 3.14 'forkserver' does. Having 'fork' in the list does not make it safe: macOS lists it, yet the default there is spawn since 3.8 because fork can crash the child through system libraries.

Examples

import multiprocessing as mp
if __name__ == '__main__':
    methods = mp.get_all_start_methods()
    print('spawn' in methods)  # → True — spawn есть везде
    print(methods[0])  # → ? умолчание: forkserver на Linux 3.14+, fork раньше, spawn на Windows и macOS
    print(mp.get_start_method(allow_none=True))  # → None — список ничего не фиксирует

See also

Open in the full glossarydocs.python.orgReport an inaccuracy