mirror of
https://github.com/python/cpython.git
synced 2025-10-09 16:34:44 +00:00
bpo-16500: Allow registering at-fork handlers (#1715)
* bpo-16500: Allow registering at-fork handlers * Address Serhiy's comments * Add doc for new C API * Add doc for new Python-facing function * Add NEWS entry + doc nit
This commit is contained in:
parent
f931fd1c2a
commit
346cbd351e
15 changed files with 365 additions and 68 deletions
|
@ -46,6 +46,7 @@ from _collections_abc import Set as _Set, Sequence as _Sequence
|
|||
from hashlib import sha512 as _sha512
|
||||
import itertools as _itertools
|
||||
import bisect as _bisect
|
||||
import os as _os
|
||||
|
||||
__all__ = ["Random","seed","random","uniform","randint","choice","sample",
|
||||
"randrange","shuffle","normalvariate","lognormvariate",
|
||||
|
@ -763,5 +764,9 @@ getstate = _inst.getstate
|
|||
setstate = _inst.setstate
|
||||
getrandbits = _inst.getrandbits
|
||||
|
||||
if hasattr(_os, "fork"):
|
||||
_os.register_at_fork(_inst.seed, when='child')
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
_test()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue