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 alternatively, make things more robust by avoiding to call the API on 
systems which are known to have blocking problems and then reverting to using 
/dev/urandom directly instead ?

Note that the RNG does already use a fallback solution for systems which don't 
provide os.urandom. Also note that os.urandom() is documented (indirectly via 
man 4 urandom) to not be blocking. If it blocks on some systems, we should add 
a work-around for those, just like Python/random.c does for Solaris.

BTW: Is there a way to determine whether enough entropy has been gathered 
without doing a blocking call ? This could be used to find out whether 
getrandom() will potentially block.

----------
nosy: +lemburg

_______________________________________
Python tracker <rep...@bugs.python.org>
<http://bugs.python.org/issue25420>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to