[Python-checkins] bpo-39108: Document threading issues for random.gauss() (GH-22928) (GH-22972)
rhettinger
webhook-mailer at python.org
Sun Oct 25 11:48:42 EDT 2020
https://github.com/python/cpython/commit/af891a962b62268d76ace0d4768ab0e1934a2cd1
commit: af891a962b62268d76ace0d4768ab0e1934a2cd1
branch: 3.9
author: Miss Skeleton (bot) <31488909+miss-islington at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2020-10-25T08:48:38-07:00
summary:
bpo-39108: Document threading issues for random.gauss() (GH-22928) (GH-22972)
files:
M Doc/library/random.rst
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index f9535d7d1b9a2..8154dfc18ccc6 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)
More information about the Python-checkins
mailing list