8000 bpo-39108: Document threading issues for random.gauss() (GH-22928) · adorilson/cpython@9c5513f · GitHub
[go: up one dir, main page]

Skip to content

Commit 9c5513f

Browse files
rhettingeradorilson
authored andcommitted
bpo-39108: Document threading issues for random.gauss() (pythonGH-22928)
1 parent 12dec2f commit 9c5513f

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)
0