This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author pitrou
Recipients Devin Jeanpierre, pitrou, vstinner
Date 2015-05-25.14:03:24
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1432562604.44.0.312126764964.issue24283@psf.upfronthosting.co.za>
In-reply-to
Content
> RuntimeError: reentrant call inside <_io.BufferedWriter name='<stdout>'>

As the exception message suggests: the IO stack is not reentrant. If an ongoing IO call is interrupted by a signal, and the signal handler calls again into the IO stack, this situation is detected and an error is raised. If instead we allowed the IO call to continue, all sorts of problems could ensue (data loss, crashes...).

So, indeed, print() is not safe in signal handlers. Though the fact that it raises an exception, rather than crashes, makes things easier for the developer ;)
History
Date User Action Args
2015-05-25 14:03:24pitrousetrecipients: + pitrou, vstinner, Devin Jeanpierre
2015-05-25 14:03:24pitrousetmessageid: <1432562604.44.0.312126764964.issue24283@psf.upfronthosting.co.za>
2015-05-25 14:03:24pitroulinkissue24283 messages
2015-05-25 14:03:24pitroucreate