
On 23 June 2016 at 17:46, Donald Stufft <donald@stufft.io> wrote:
On Jun 23, 2016, at 8:33 PM, Nick Coghlan <ncoghlan@gmail.com> wrote:
The argument chain runs:
- if such software doesn't exist, it doesn't matter which behaviour we choose - if we're wrong and it does exist, we can choose how it fails: - blocking (with associated potential for init system deadlock) - throwing an exception
Given the choice between debugging an apparent system hang and an unexpected exception when testing against a new version of a platform, I'll choose the exception every time.
I think the biggest argument to blocking is that there really exist two sort of situations that blocking can happen in:
* It blocks for a tiny amount (maybe <1s) and nobody ever notices and people feel like things “just work”. * It blocks for a long amount of time (possibly forever depending on where in the boot sequence Python is being used) and it hangs for a long time (or forever).
In the second case I think it’s pretty obvious that an exception is better than hanging forever, but in the first case an exception might actually cause people to go out of their way to do something bad to “stop the pain”. My personal preference is waffling back and forth between them based on which of the two above I feel are more likely to occur in practice.
That's fair, and it's a large part of why I realised PEP 522 needed a standard library answer for "just wait until the system RNG is ready, please". I'll also note that I'm open to being convinced that it's OK for "import secrets" to be that answer - my main argument against it is just a general principle that imports shouldn't have side effects, and blocking waiting for an external state change is a side effect. Standing against that is the argument that we wouldn't want the recommended idiom for using the secrets module to become the boilerplatish: import secrets secrets.wait_for_system_rng() Cheers, Nick. -- Nick Coghlan | ncoghlan@gmail.com | Brisbane, Australia