On 6 September 2012 16:34, Steven D'Aprano < steve+comp.lang.pyt...@pearwood.info> wrote:
> On Thu, 06 Sep 2012 00:34:56 +0000, Antoine Pitrou wrote: > > Monkey-patching globals is not thread-safe: other threads will see your > > modification, which is risky and fragile. > > Isn't that assuming that you don't intend the other threads to see the > modification? > > If I have two functions in my module that call "open", and I monkey-patch > the global (module-level) name "open" to intercept that call, I don't see > that there is more risk of breakage just because one function is called > from a thread. > > Obviously monkey-patching the builtin module itself is much riskier, > because it doesn't just effect code in my module, it affects *everything*. It's not as though the option to monkey-patch has been taken away. But hopefully there is now less of a need for it. Tim Delaney
-- http://mail.python.org/mailman/listinfo/python-list