From: Raymond Hettinger Date: Sun, 25 Oct 2020 14:59:01 +0000 (-0700) Subject: bpo-39108: Document threading issues for random.gauss() (GH-22928) X-Git-Tag: v3.10.0a2~76 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=3cde3788b68bce7deee1e6d31e265bbfce337731;p=thirdparty%2FPython%2Fcpython.git bpo-39108: Document threading issues for random.gauss() (GH-22928) --- diff --git a/Doc/library/random.rst b/Doc/library/random.rst index 5a9359484d11..c243aced986e 100644 --- a/Doc/library/random.rst +++ b/Doc/library/random.rst @@ -319,6 +319,13 @@ be found in any statistics text. deviation. This is slightly faster than the :func:`normalvariate` function defined below. + Multithreading note: When two threads call this function + simultaneously, it is possible that they will receive the + same return value. This can be avoided in three ways. + 1) Have each thread use a different instance of the random + number generator. 2) Put locks around all calls. 3) Use the + slower, but thread-safe :func:`normalvariate` function instead. + .. function:: lognormvariate(mu, sigma)