Open TobiasWinchen opened 6 years ago
The bug also affects ObserverFeatures and Modules written in python. However,
source.add(MySourceFeature()) will fail;
sf = MySourceFeature() source.add(sf)
will work. The reason is that in the former case the object is deleted by python. See also: https://github.com/swig/swig/issues/779
Monkey patching ( https://github.com/swig/swig/issues/723) might be a solution to disown the created object first but is surely an ugly solution.
It is the same issue I had almost 3 years ago, see #27 . Disown is, I agree, an ugly solution, while the one where the python is taking care of the ownership is what I regularly use and it works.
I would write a recommendation how to handle this on the wiki, section about extending CRPropa from Python, and close the issue. I'm afraid we cannot do more.
I had this problem, too.
I agree with Andrej let's just put an explanation in the wiki and maybe a comment in the example for the source feature. So when the example is used people will know why the object has to be created outside of the class attributes.
Okay, I will add a tag `Won't fix' to the bug to mark that we won't work on it, but I don't think that we should close such issues. If #27 hadn't been closed it would have saved me the time figuring out the problem.
This is from the examples and reproduces the bug
occures not always; occures in single threaded and multi threaded execution