Hi,
I am trying to parallelize some calculations steered by python using the multiprocess module. What I do is have some python class which contains a C++ ROOT class (it inherits from TObject, compiled with ACLIC, all the usual stuff). This ROOT class is a Minuit2 wrapper, and performs a minimization.
What I want to do is have a multiprocessing.Pool of diferent parameters which I want to minimize, and pass it the Python Class (calibrator in the example) which contains the C++ class already instantiated (this is because the setup of the C++ class is a little bit slow).
This _processFunction calls a the minimize class of the calibrator, which in turn calls the Minuit2->Minimize().
It seems very complicated but this setup is working nicely if I just work with plain python (no multiprocessing). As soon as I use multiprocessing, the line above produces an error which I assume is caused because the os.fork done by the multiprocessing module is not working correctly.
>>> mgr.process(calib, [('2497','1598'),('3507','588'),('5369','6918')])
Error in <TClass::BuildRealData>: Cannot find any ShowMembers function for ROOT::Minuit2::Minuit2Minimizer!
Error in <TClass::BuildRealData>: Cannot find any ShowMembers function for ROOT::Math::Functor!
Error in <TClass::BuildRealData>: Cannot find any ShowMembers function for ROOT::Minuit2::Minuit2Minimizer!
Error in <TClass::BuildRealData>: Cannot find any ShowMembers function for ROOT::Math::Functor!
Has anybody done something similar to what I am intending to do? I could go for the dirty solution of instantiating the C++ class after the fork, but that would slow down the processing a great deal. In principle there should be no reason why this isn’t working, so probably I am doing something wrong. Any ideas?
Cheers,
Albert
PS: Since the code is obviously a little bit complicated, I haven’t posted any “simplified” version, just in case things are obvious and the solution is straightforward. If necessary, I will try to produce a simplified code.