Traceback (most recent call last):
File “TestPyROOT.py”, line 191, in
sys.exit(main())
File “TestPyROOT.py”, line 158, in main
myThread = TThread(“myThread”,filler_function)
TypeError: none of the 5 overloaded methods succeeded. Full details:
TThread::TThread(long id = 0) =>
takes at most 1 arguments (2 given)
TThread::TThread(void*()(void) fn, void* arg = 0, TThread::EPriority pri = kNormalPriority) =>
could not convert argument 1
TThread::TThread(void()(void) fn, void* arg = 0, TThread::EPriority pri = kNormalPriority) =>
could not convert argument 1
TThread::TThread(const char* thname, void*()(void) fn, void* arg = 0, TThread::EPriority pri = kNormalPriority) =>
could not convert argument 2
TThread::TThread(const char* thname, void()(void) fn, void* arg = 0, TThread::EPriority pri = kNormalPriority) =>
could not convert argument 2
Can you please tell me how can I use TThread in PyROOT ?
Many thanks,
TThread has not been “pythonized” and function pointers are not generally supported (they could, but someone would need to develop it: file a JIRA feature request if it is important for you).
Until then, python supports threads also (see module threading).
Note that python has a “global interpreter lock” so multi-threading python-based functions do not do what you may think they do. For calls to C++ functions, use the _threaded member of functions to tell them to release the GIL upon call.
I"m not sure I understand your last sentence (mind, I’m not a an expert programmer).
Are you saying that I can use the python threader to do what I want to do in my simple example ?
Can you please tell me how ?
the point of the last sentence is that pure python functions never run in parallel, so if you use python threads it should only be for logical task composition (i.e. code structural or simply convenience) or b/c you can call C++ (where the GIL can be released, but in the case of PyROOT, you have to explicitly do so by setting _threaded). In all other cases, the parallel code will be slower than the serial code, making it pointless.