attempt to install idle handler twice?

Hello,

I have a thread like:

class StopMarker:
    """This is used as an individual stopper item."""

class Logger(threading.Thread):
    def __init__(self, parent):
        threading.Thread.__init__(self)
        self.parent = parent
        self.pqueue = parent.pqueue
        self.stopper = StopMarker()

    def run(self):
        while 1:
          try:
            if not self.pqueue.empty():
                item = self.pqueue.get()
                if item is self.stopper:
                  self.parent.SetStatusText("byebye")
                  break
                self.parent.SetStatusText(item)
            time.sleep(0.1)
          except:
            print 'bubu '

    def stop(self):
        self.pqueue.put(self.stopper)
        self.join()

which receives messages from a queue and update a status text inside the
parent frame. It seems to work fine, but after some time I get strange
exceptions, which I decided to catch in the above thread. Here is the
console output:

[Debug] 04:39:17 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu
[Debug] 04:48:04 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu
[Debug] 04:56:23 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu
[Debug] 05:22:33 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu
[Debug] 05:35:28 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu
[Debug] 06:13:39 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu
[Debug] 06:44:31 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu
[Debug] 06:52:55 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu
[Debug] 06:58:07 PM: C++ assertion "wxTheApp->m_idleTag == 0" failed in
/usr/src/redhat/BUILD/wxPythonSrc-2.4.0.2/src/gtk/app.cpp(364): attempt
to install idle handler twice
bubu

were timestamps indicate rather long term exceptions behaviour. Finally
I get:

Gdk-CRITICAL **: file gdkregion.c: line 69 (gdk_region_empty): assertion
`region != NULL' failed.

Gdk-CRITICAL **: file gdkregion.c: line 245 (gdk_regions_intersect):
assertion `source2 != NULL' failed.

Gdk-CRITICAL **: file gdkregion.c: line 99 (gdk_region_get_clipbox):
assertion `region != NULL' failed.

Gdk-CRITICAL **: file gdkregion.c: line 69 (gdk_region_empty): assertion
`region != NULL' failed.

Gdk-CRITICAL **: file gdkregion.c: line 268 (gdk_regions_union):
assertion `source2 != NULL' failed.

Gdk-CRITICAL **: file gdkregion.c: line 69 (gdk_region_empty): assertion
`region != NULL' failed.

and parent wxPython Frame is then 'white'. I have wxPython-2.3.3.1
running on Linux RedHat 7.3. Any ideas why this behaviour?

···

--

                         _____
      Swiss / / juraj.krempasky@psi.ch
     _/_/_/ _/ _/_/_/ /____ Experimental Division
    _/ _/ _/ Source / Paul Scherrer Institute
     _/_/ _/ _/_/ ____/ CH-5232 Villigen-PSI
        _/_/Light _/ / Tel: ++41 56 310 5131
_/_/_/_/_/_/_/ _/_/_/___/ Fax: ++41 56 310 3151

Juraj Krempasky wrote:

Hello,

I have a thread like:

class StopMarker:
    """This is used as an individual stopper item."""

class Logger(threading.Thread):
    def __init__(self, parent):
        threading.Thread.__init__(self)
        self.parent = parent
        self.pqueue = parent.pqueue
        self.stopper = StopMarker()

    def run(self):
        while 1:
          try:
            if not self.pqueue.empty():
                item = self.pqueue.get()
                if item is self.stopper:
                  self.parent.SetStatusText("byebye")
                  break
                self.parent.SetStatusText(item)
            time.sleep(0.1)
          except:
            print 'bubu '

    def stop(self):
        self.pqueue.put(self.stopper)
        self.join()

which receives messages from a queue and update a status text inside the
parent frame. It seems to work fine, but after some time I get strange
exceptions, which I decided to catch in the above thread. Here is the
console output:

You can't call GUI functions from a non-gui thread. Try using this instead:

  wxCallAfter(self.parent.SetStatusText, item)

···

--
Robin Dunn
Software Craftsman
http://wxPython.org Java give you jitters? Relax with wxPython!