Monkey patch an entire file in a python package

Chris Angelico rosuav at gmail.com
Tue Mar 24 08:10:48 EDT 2015


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



More information about the Python-list mailing list