[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2016-04-26 Thread STINNER Victor
STINNER Victor added the comment: > so i maintain that this issue is in fact very specific to the random module I think that you misunderstood the issue. I'm now closing it as a duplicate of the issue #26839. -- Marc-Andre Lemburg: Please continue the discussion on the issue #26839. I

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2016-04-26 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: I still believe the underlying system API use should be fixed rather than all the different instances where it gets used. getrandom() should not block. If it does on a platform, that's a bug on that platform and Python should revert to the alternative of

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2016-04-26 Thread jan matejek
jan matejek added the comment: unlike #26839, however, there is no workaround for "import random". so i maintain that this issue is in fact very specific to the random module -- ___ Python tracker

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2016-04-26 Thread STINNER Victor
STINNER Victor added the comment: The issue is more general than just "import random", Python reads entropy at startup to initialize a random seed for its randomized hash function: see the issue #26839. -- ___ Python tracker

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2016-04-26 Thread Raymond Hettinger
Raymond Hettinger added the comment: FWIW, the random.patch from matejcik makes me uncomfortable. It feels like a hack that obscures the code, would confound linters and type checkers, and would create more problems than it would solve. -- assignee: rhettinger ->

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-12-23 Thread Thomas Petazzoni
Thomas Petazzoni added the comment: I can confirm that I'm affected by the same issue. Booting a simple Linux system on a Qemu ARM platform, the python startup hangs during 25 seconds due to the call to getrandom(). I am not doing anything with Python, just starting the Python interpreter: #

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-12-23 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- assignee: -> rhettinger ___ Python tracker ___ ___

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-12-23 Thread Thomas Petazzoni
Thomas Petazzoni added the comment: Obviously I did my math wrong: it waits 45 seconds in getrandom(), not 25 seconds. See my strace log. -- ___ Python tracker

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-12-23 Thread STINNER Victor
STINNER Victor added the comment: getrandom() is used to initialize the randomized hash function. Set PYTHONHASHSEED env var to not use getrandom() at startup. But the hash function will not randomized anymore :-/ -- ___ Python tracker

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-20 Thread STINNER Victor
STINNER Victor added the comment: I knew the subtle difference between reading from /dev/urandom and getrandom() syscall: the syscall hangs until /dev/urandom is feeded with enough entropy. It should be documented in Whats New, os.urandom and maybe also random doc. Not only python 3.5 was

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-20 Thread Марк Коренберг
Марк Коренберг added the comment: Man getrandom() As of Linux 3.19, the following bug exists: * Depending on CPU load, getrandom() does not react to interrupts before reading all bytes requested. So, is it goot to use this syscall now? --

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-20 Thread STINNER Victor
STINNER Victor added the comment: Hi, Марк Коренберг added the comment: > Man getrandom() > > As of Linux 3.19, the following bug exists: > >* Depending on CPU load, getrandom() does not react to interrupts > before reading all bytes requested. > > So, is it goot to use this

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-20 Thread STINNER Victor
STINNER Victor added the comment: > The RNG is seeded from os.urandom, which as of python 3.5 uses the > potentially blocking getrandom() call. Here is a patch for os.urandom() documentation. What do you think? -- keywords: +patch Added file:

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-20 Thread Serhiy Storchaka
Changes by Serhiy Storchaka : -- nosy: +rhettinger ___ Python tracker ___ ___

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-20 Thread jan matejek
jan matejek added the comment: let me reiterate that what I consider a bug is the fact that "import random" statement calls os.urandom (which per the proposed documentation may sometimes block) IOW, "import random" may sometimes block, even though it is not actually used at any point (could

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-20 Thread Marc-Andre Lemburg
Marc-Andre Lemburg added the comment: I think Jan has a point there. An import should not cause the whole interpreter to hang. Wouldn't it be possible to have the getrandom() call be done lazily to avoid this and only have it block when the RNG from the random is actually being used ? Or

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-20 Thread jan matejek
jan matejek added the comment: attaching a first draft of what i'd consider a solution? not sure if this is the right way to go, and i don't know how to write a test for an import statement -- Added file: http://bugs.python.org/file40820/random.patch

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-19 Thread jan matejek
jan matejek added the comment: On 18.10.2015 23:09, STINNER Victor wrote: > Hum ok, so your issue is specific to Linux. yes, should have specified that, sorry > Hum, the problem was already fixed some months/years ago: you must attach a > RNG virtio device to your VM. Python is just one

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-19 Thread STINNER Victor
STINNER Victor added the comment: If your OS has no entropy at all, you will have much more severe issue. For example, don't try to generate a SSH key or established a SSL/TLS session. -- ___ Python tracker

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-19 Thread Марк Коренберг
Марк Коренберг added the comment: Just install rngd and setup it to user /dev/urandom as entropy source. I think thread is closed :) -- nosy: +mmarkk ___ Python tracker

[issue25420] "import random" blocks on entropy collection on Linux with low entropy

2015-10-18 Thread STINNER Victor
STINNER Victor added the comment: "The RNG is seeded from os.urandom, which as of python 3.5 uses the potentially blocking getrandom() call." Hum ok, so your issue is specific to Linux. "This causes problems e.g. on our build VMs that don't have true entropy, so getrandom() blocks forever"