[Python-checkins] bpo-39108: Document threading issues for random.gauss() (GH-22928)
rhettinger
webhook-mailer at python.org
Sun Oct 25 10:59:10 EDT 2020
https://github.com/python/cpython/commit/3cde3788b68bce7deee1e6d31e265bbfce337731
commit: 3cde3788b68bce7deee1e6d31e265bbfce337731
branch: master
author: Raymond Hettinger <rhettinger at users.noreply.github.com>
committer: rhettinger <rhettinger at users.noreply.github.com>
date: 2020-10-25T07:59:01-07:00
summary:
bpo-39108: Document threading issues for random.gauss() (GH-22928)
files:
M Doc/library/random.rst
diff --git a/Doc/library/random.rst b/Doc/library/random.rst
index 5a9359484d11a..c243aced986e5 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