Skip to content

Commit af891a9

Browse files
bpo-39108: Document threading issues for random.gauss() (GH-22928) (GH-22972)
1 parent 2990aef commit af891a9

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

Doc/library/random.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -319,6 +319,13 @@ be found in any statistics text.
319319
deviation. This is slightly faster than the :func:`normalvariate` function
320320
defined below.
321321

322+
Multithreading note: When two threads call this function
323+
simultaneously, it is possible that they will receive the
324+
same return value. This can be avoided in three ways.
325+
1) Have each thread use a different instance of the random
326+
number generator. 2) Put locks around all calls. 3) Use the
327+
slower, but thread-safe :func:`normalvariate` function instead.
328+
322329

323330
.. function:: lognormvariate(mu, sigma)
324331

0 commit comments

Comments
 (0)