I'm using start_new_thread() from the tread module. Everything seems
to work fine until I exit the application. The docs for
start_new_thread() claim that 'When the function returns, the thread
silently exits.', but when I exit the application after a complete run
of the function fed to start_new_thread() I receive the error:
Exception exceptions.KeyError: KeyError(####,) in <module 'threading'
from 'C:\Python25\lib\threading.pyc'> ignored
The number always seems to be different. Do I still need to do
something to do some cleanup in my app before it closes, or can I just
ignore this, as it is indicated that the error itself is ignored?
I'm using start_new_thread() from the tread module. Everything seems
to work fine until I exit the application. The docs for
start_new_thread() claim that 'When the function returns, the thread
silently exits.', but when I exit the application after a complete run
of the function fed to start_new_thread() I receive the error:
Exception exceptions.KeyError: KeyError(####,) in<module 'threading'
from 'C:\Python25\lib\threading.pyc'> ignored
The number always seems to be different.
It's probably the thread ID.
Do I still need to do
something to do some cleanup in my app before it closes, or can I just
ignore this, as it is indicated that the error itself is ignored?
You can ignore it but it would be nice to figure out why it is happening. Exceptions at cleanup time usually indicate that there is some unexpected references to objects that are preventing them from being cleaned up earlier, perhaps a global or a reference cycle that the garbage collector is breaking, and that object's __del__ is trying to do something it can't because other objects it needs are already gone.
Are you sure the thread has completed and exited at that point? Have you tried calling its join method from the GUI thread after the MainLoop exits? (That will make the GUI thread wait until the worker thread exits.)
I'll try calling the join method. I'm also going to try using the
treading module instead of thread. It's described as a higher level
threading module, it may take care of what ever I may be missing.
Thanks for the suggestion
···
On Aug 4, 3:09 pm, Robin Dunn <ro...@alldunn.com> wrote:
On 8/3/10 12:38 PM, Josh Russo wrote:
> I'm using start_new_thread() from the tread module. Everything seems
> to work fine until I exit the application. The docs for
> start_new_thread() claim that 'When the function returns, the thread
> silently exits.', but when I exit the application after a complete run
> of the function fed to start_new_thread() I receive the error:
> Exception exceptions.KeyError: KeyError(####,) in<module 'threading'
> from 'C:\Python25\lib\threading.pyc'> ignored
> The number always seems to be different.
It's probably the thread ID.
> Do I still need to do
> something to do some cleanup in my app before it closes, or can I just
> ignore this, as it is indicated that the error itself is ignored?
You can ignore it but it would be nice to figure out why it is
happening. Exceptions at cleanup time usually indicate that there is
some unexpected references to objects that are preventing them from
being cleaned up earlier, perhaps a global or a reference cycle that the
garbage collector is breaking, and that object's __del__ is trying to do
something it can't because other objects it needs are already gone.
Are you sure the thread has completed and exited at that point? Have
you tried calling its join method from the GUI thread after the MainLoop
exits? (That will make the GUI thread wait until the worker thread exits.)
Ok, I fixed it. There must be something strange going on in the
start_new_thread() function. I basically just mimicked it with my own
thread class and it works perfectly:
Not sure if I can but maybe tomorrow I'll peak under the hood to see
what start_new_thread is actually doing.
···
On Aug 4, 8:06 pm, Josh Russo <josh.r.ru...@gmail.com> wrote:
On Aug 4, 3:09 pm, Robin Dunn <ro...@alldunn.com> wrote:
> On 8/3/10 12:38 PM, Josh Russo wrote:
> > I'm using start_new_thread() from the tread module. Everything seems
> > to work fine until I exit the application. The docs for
> > start_new_thread() claim that 'When the function returns, the thread
> > silently exits.', but when I exit the application after a complete run
> > of the function fed to start_new_thread() I receive the error:
> > Do I still need to do
> > something to do some cleanup in my app before it closes, or can I just
> > ignore this, as it is indicated that the error itself is ignored?
> You can ignore it but it would be nice to figure out why it is
> happening. Exceptions at cleanup time usually indicate that there is
> some unexpected references to objects that are preventing them from
> being cleaned up earlier, perhaps a global or a reference cycle that the
> garbage collector is breaking, and that object's __del__ is trying to do
> something it can't because other objects it needs are already gone.
> Are you sure the thread has completed and exited at that point? Have
> you tried calling its join method from the GUI thread after the MainLoop
> exits? (That will make the GUI thread wait until the worker thread exits.)
I'll try calling the join method. I'm also going to try using the
treading module instead of thread. It's described as a higher level
threading module, it may take care of what ever I may be missing.