Threading causes core dump when daemonic thread exits

Hello,

I’m trying to write a GUI which has
some threading capability.

The main thread handles the GUI. At
user request, the main thread starts a job performed by separate daemonic
thread.

When the daemonic thread is finished, it
triggers an event with PostEvent, and data is delivered back to the main GUI.

Based on my debugging efforts, it seems
that the following is the order of events:

  1.  User
    

requests job.

  1.  Main
    

GUI starts daemonic thread

  1.  Daemonic
    

thread performs job

  1.  Daemonic
    

thread calls PostEvent, then reaches the end of its commands (does it exit
at this point?)

  1.  PostEvent
    

triggers event in Main GUI, which successfully completes all operations in
the event handler.

  1.  Right
    

when everything is complete, the program crashes. Error message: “Segmentation
fault (core dumped).”

Any ideas?

Thanks,

Eric

Does the even object have any attributes or references to items that exist only in the worker thread? Do you derive your event class from wx.PyEvent or wx.PyCommandEvent?

···

On 7/14/11 12:49 PM, Eric Zhao wrote:

Hello,

I�m trying to write a GUI which has some threading capability.

The main thread handles the GUI. At user request, the main thread starts
a job performed by separate daemonic thread.

When the daemonic thread is finished, it triggers an event with
PostEvent, and data is delivered back to the main GUI.

Based on my debugging efforts, it seems that the following is the order
of events:

   1. User requests job.
   2. Main GUI starts daemonic thread
   3. Daemonic thread performs job
   4. Daemonic thread calls PostEvent, then reaches the end of its
      commands (does it exit at this point?)
   5. PostEvent triggers event in Main GUI, which successfully completes
      all operations in the event handler.
   6. Right when everything is complete, the program crashes. Error
      message: �Segmentation fault (core dumped).�

Any ideas?

--
Robin Dunn
Software Craftsman