Monkey patch an entire file in a python package

enjoyaol at gmail.com enjoyaol at gmail.com
Tue Mar 24 08:34:10 EDT 2015


Le mardi 24 mars 2015 13:11:33 UTC+1, Chris Angelico a écrit :
> On Tue, Mar 24, 2015 at 10:50 PM,  <enjoyaol at gmail.com> wrote:
> > I am trying to use multiprocessing with freeze. It appears there is some bug when using multiprocessing on freezed python code on windows platforms. There is this patch which made its way to python 3.2, and works in 2.7:
> >
> > http://bugs.python.org/file20603/issue10845_mitigation.diff
> >
> > I would like to monkey patch it.
> 
> Do you have to monkey-patch at run-time? It might be better to simply
> patch your Python installation once, and then have the change deployed
> globally. Given that it was applied to 3.2, I doubt it's going to
> break much, so you can probably afford to just edit the file and have
> done with it.
> 
> Alternatively, you may be able to put your own forking.py earlier in
> PYTHONPATH, and thus shadow the stdlib module. That might require you
> to shadow all of multiprocessing, though.
> 
> ChrisA

Unfortunately, I would need to do it at runtime.
I will look into the PYTHONPATH idea, thanks



More information about the Python-list mailing list