Your message dated Tue, 26 Jan 2010 21:44:54 -0800
with message-id <[email protected]>
and subject line Re: Bug#543474: closed by Ben Hutchings <[email protected]> 
(Re: libwxgtk2.6-0: appending text to TextCtrl crashes in unpredictable ways)
has caused the Debian Bug report #543474,
regarding library is not thread-safe
to be marked as done.

This means that you claim that the problem has been dealt with.
If this is not the case it is now your responsibility to reopen the
Bug report if necessary, and/or fix the problem forthwith.

(NB: If you are a system administrator and have no idea what this
message is talking about, this may indicate a serious mail system
misconfiguration somewhere. Please contact [email protected]
immediately.)


-- 
543474: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=543474
Debian Bug Tracking System
Contact [email protected] with problems
--- Begin Message ---
Package: libwxgtk2.6-0
Version: 2.6.3.2.2-3
Severity: grave
Justification: renders package unusable

using wxpython, I am writing a very simple GUI around a command-line
program that produces logging.  I have written a simple handler class,
derived from logging.handler and owning a TextCtrl.  this is its 'emit'
method:

    def emit(self, record):
        if record.levelno >= logging.WARNING:
            styleForLevel = wx.TextAttr("red")
        elif record.levelno >= logging.INFO:
            styleForLevel = wx.TextAttr("black")
        else:
            styleForLevel = wx.TextAttr("grey")
        self.textCtrl.SetDefaultStyle(styleForLevel)

        self.textCtrl.AppendText(self.format(record))
        self.textCtrl.AppendText('\n')

the original command-line main program is running in its own thread.
I have undressed it down to this simple thing and it still causes
the crash:

def main(options, args):
    import time
    for i in range(33):
        log.warning('this is warning #%d' % i)
        for j in range(10):
            log.info('and this is informational message #%d' % j)
        time.sleep(0.1)


on windows it works (quite sadly, I don't manage to make it crash),
on linux (and I've tried ubuntu 9.04, Debian-powerpc-sid, Debian-amd64)
it crashes in quite a few different ways.  that '33' is just a random
number, it usually crashes in the first 10 iterations.

I am filing it under libwxgtk2.6-0 but maybe it belongs to both
python-wxgtk2.6 and python-wxgtk2.8.


-- System Information:
Debian Release: squeeze/sid
  APT prefers unstable
  APT policy: (500, 'unstable'), (500, 'stable'), (1, 'experimental')
Architecture: powerpc (ppc)

Kernel: Linux 2.6.30-1-powerpc
Locale: LANG=en_DK.UTF-8, LC_CTYPE=en_DK.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages libwxgtk2.6-0 depends on:
ii  libatk1.0-0            1.26.0-1          The ATK accessibility toolkit
ii  libc6                  2.9-24            GNU C Library: Shared libraries
ii  libesd-alsa0 [libesd0] 0.2.41-5          Enlightened Sound Daemon (ALSA) - 
ii  libexpat1              2.0.1-4           XML parsing C library - runtime li
ii  libgcc1                1:4.4.1-2         GCC support library
ii  libgl1-mesa-glx [libgl 7.5-3+b1          A free implementation of the OpenG
ii  libglib2.0-0           2.20.4-1          The GLib library of C routines
ii  libglu1-mesa [libglu1] 7.5-3+b1          The OpenGL utility library (GLU)
ii  libgtk2.0-0            2.16.5-1+b1       The GTK+ graphical user interface 
ii  libjpeg62              6b-15             The Independent JPEG Group's JPEG 
ii  libpango1.0-0          1.24.5-1+b1       Layout and rendering of internatio
ii  libpng12-0             1.2.39-1          PNG library - runtime
ii  libstdc++6             4.4.1-2           The GNU Standard C++ Library v3
ii  libtiff4               3.9.0-1           Tag Image File Format (TIFF) libra
ii  libwxbase2.6-0         2.6.3.2.2-3       wxBase library (runtime) - non-GUI
ii  libxinerama1           2:1.0.3-2         X11 Xinerama extension library
ii  zlib1g                 1:1.2.3.3.dfsg-15 compression library - runtime

libwxgtk2.6-0 recommends no packages.

Versions of packages libwxgtk2.6-0 suggests:
ii  libgnomeprintui2.2-0          2.18.4-1   GNOME 2.2 print architecture User 

-- no debconf information



--- End Message ---
--- Begin Message ---
Hi Mario,

On Tue, Dec 01, 2009 at 02:49:03PM +0100, Mario Frasca wrote:
> On 2009-1201 12:54:14, Debian Bug Tracking System wrote:
> > From: Ben Hutchings <[email protected]>
> >
> > [...]
> > See <http://library.gnome.org/devel/gtk-faq/stable/x481.html>.
> > 
> > Ben.
> 
> hey Ben,
> 
> thanks for looking into this.  I think I would like to reopen this report
> reassigning it to the python-wxgtk2.8 package.  the fact is, your answer
> does indicate the most probable source of my original python problem,
> but does not solve it yet!
> 
> you see, in my python programs I am not using gtk directly, just 'wx'
> and 'threading'.
> 
> having to invoke these two functions (in which python library do I find
> them?) each and every time I make a wx call (that I assume might be
> translated into a call to a gtk function) would produce quite clumsy
> code I'm afraid...
> 

you should use wx.CallAfter. it will cause the function to be ran in
the main thread in a thread safe way.
Here's a wiki page on it: http://wiki.wxpython.org/CallAfter

> my suggestion is to add a setting in the python wx library that makes
> the library thread-safe (or make the library thread-safe by default)...
> 

this just isn't how it works. you have unreal expectations of the
library.

attached is an example I wrote which demonstrates wx.CallAfter. It
shows both the wrong way (AppendText in the thread) and the right way
(using wx.CallAfter in the thread to have the main thread run
AppendText).

closing bug report.

Cheers,
Ryan
(sorry for taking so long to get back to you)

-- 
_________________________
Ryan Niebur
[email protected]

Attachment: signature.asc
Description: Digital signature


--- End Message ---

Reply via email to