[issue6647] warnings.catch_warnings is not thread-safe
A.M. Kuchling li...@amk.ca added the comment: Added a warning to 2.x trunk in r79607, and Gabriel's doc change in r79608. This thread-unsafety seems specialized and rarely of great importance, so I used the note:: directive, not warning::. -- nosy: +akuchling resolution: - fixed status: open - closed ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6647 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6647] warnings.catch_warnings is not thread-safe
Gabriel Genellina gagsl-...@yahoo.com.ar added the comment: Document that warnings.catch_warnings is not thread safe. -- keywords: +patch Added file: http://bugs.python.org/file15341/warnings.diff ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6647 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6647] warnings.catch_warnings is not thread-safe
Antoine Pitrou pit...@free.fr added the comment: Any function whose purpose is to mutate global (non thread-local) state is inherently thread-unsafe. The only reasonable possibility is to document it as such. -- assignee: - georg.brandl components: +Documentation nosy: +georg.brandl, pitrou ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6647 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com
[issue6647] warnings.catch_warnings is not thread-safe
New submission from Gabriel Genellina gagsl-...@yahoo.com.ar: warnings.catch_warnings is a context manager supposed to save and restore warnings filters, and optionally record all warnings issued. But it does so in a completely thread-unsafe way, by replacing the module's showwarning and filters attributes on enter, and restoring them on exit. If the __enter__ / __exit__ calls of two threads overlap, after leaving the last block the warnings state is not the same as the original state, as it should be. I don't know how to fix this, other than using locks (that could block indefinitely) or severely restricting how catch_warnings may be used. At least, this issue should be documented. -- components: Library (Lib) files: error-warnings.py messages: 91301 nosy: gagenellina severity: normal status: open title: warnings.catch_warnings is not thread-safe type: behavior versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2 Added file: http://bugs.python.org/file14654/error-warnings.py ___ Python tracker rep...@bugs.python.org http://bugs.python.org/issue6647 ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com