Posts: 43
Joined: Dec 2009
Reputation:
1
2010-11-01, 15:38
Hi, I'm coding a multi threading process and if I quit XBMC before all threads are finished, I get a C++ execution error, and the log refers to:
msg: Fatal Python error: Py_EndInterpreter: not the last thread
So I had tried to use "signal" to catch the interruption and launch a cleanup function, but it didn't worked because the addon itself isn't the main thread.
Anyone have any experience handling this?
Posts: 149
Joined: May 2008
Reputation:
5
analogue
Skilled Python Coder
Posts: 149
Make sure all the threads you have spawned in your python code have terminated before you allow your python script to exit. See util.py and home.py in mythbox for more details.
Posts: 53
Joined: Nov 2009
Reputation:
0
Track all the threads you create and at the end of your script just thread.join() on them all. Although xbmc should probably not segfault when an error like this occurs!
Posts: 2,710
Joined: Feb 2009
Reputation:
12
ppic
Skilled Python Coder
Posts: 2,710
i've got this problem with tvtunes too if i quit xbmc when i'm in library.
Posts: 53
Joined: Nov 2009
Reputation:
0
I see what you are getting at. I don't think the script itself should have a cleanup function but xbmc should handle killing the threads gracefully without crashing itself. Try submitting a ticket to trac about this with a testcase.
Posts: 53
Joined: Nov 2009
Reputation:
0
That turned out to be an unrelated bug. I'm curious, what causes XBMC to halt script execution suddenly? The only thing I can remember that might do that is I saw a function called stopscript in the builtins.