Monkey patch an entire file in a python package

enjoyaol at gmail.com enjoyaol at gmail.com
Tue Mar 24 07:50:54 EDT 2015


This question is about python 2.7 on Windows 7

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.

Problem is, this patch is for "forking.py", used by multiprocessing.Pools Multiprocessing is using forking.py to launch processes. I would like to monkey patch this way :

import multiprocessing
import multiprocessing_fixed
multiprocessing_fixed:

import multiprocessing.forking as mpf
def prepare(data):
    [include fixed code for this method]
mpf.prepare = prepare_pyz
It's not working because forking.py is launched like a python module.

How to solve this problem ?

Thanks



More information about the Python-list mailing list