Python/Tkinter crash.

Hendrik van Rooyen mail at microcorp.co.za
Thu Oct 5 04:26:07 EDT 2006


 "Hendrik van Rooyen" <mail at microcorp.co.za> wrote:
>  "Eric Brunel" <eric_brunel at despammed.com> wrote:
>
>
> > On Wed, 04 Oct 2006 10:33:55 +0200, Hendrik van Rooyen
> > <mail at microcorp.co.za> wrote:
> >
> > > Hi,
> > >
> > > I get the following:
> > >
> > > hvr at LINUXBOXMicrocorp:~/Controller/lib> python display.py
> > > UpdateStringProc should not be invoked for type font
> > > Aborted
> > >
> > > and I am back at the bash prompt - this is most frustrating, as there is
> > > no
> > > friendly traceback to help me guess where its coming from.
> > >
> > > And what is worse, the script runs for a varying time before it simply
> > > exits
> > > like this.
> > >
> > > What can I do to dig deeper to try to find a clue? - I don't even know
> > > if its
> > > Python, Tkinter or Linux...
> >
> > Neither of them: it's a tcl problem. The message you get is in the file
> > generic/tclObj.c in the tcl source directory.
> >
> > I know the problem happens sometimes on one of my Tkinter applications,
> > but I never succeeded in reproducing it systematically. I've browsed the
> > tcl bugs, but didn't find anything. Maybe you'll be luckier than I... If
> > you are, I'm interested in any hint you can find.
>
> Ouch! - this is a bit the wrong answer...
>
> What I have seen, in mucking about today, is that it seems to be related to
> threading - I have a silly sort of thread that runs, updating my meters, more
or
> less continuously, to simulate data from the field - it just adds some values
to
> the seven display variables and calls the update methods that delete and
redraw
> the arcs representing the analogue style meters, deleting and replacing the
text
> objects that show the values, and then it sleeps for a while, and does it all
> again.
>
> At the same time, one other thread (other than the main thread), can be
created
> to move a component on the canvas around by calling its delete and draw
> methods. - but this is also done more or less continuously, as a new thread is
> created as soon as the previous one dies to move the next object around.
>
> Now these two things are asynchronous with each other, so that given enough
> time, they are bound to make calls to Tkinter in a re-entrant fashion, and I
> suspect that it is this that is causing the problem - my "evidence" for this
is
> that I implemented a boolean as a sort of "lock" and had the Meter updating
back
> down in favour of the other animation to try and avoid any sort of re -
entrancy
> to the Tkinter canvas object's  delete and draw methods...
>
> Now the Jury is still out on this - it seems to have helped, as the thing has
> been running for some hours now without crashing - but maybe I have just
applied
> a band aid to sword cut - I don't know - if it runs through the night I will
> feel much better...
>
> Will update again as soon as I have more data...

OK - It has run through the night and as I type it is still running, so the band
aid has helped a bit...

Eric - if you are interested and contact me, then I will comment out the "fix"
and email you the bits that you need to run this horror - if you need a reliably
failing thingy to study the problem with :-)
It was your post yesterday or so in another thread here that prompted me to try
this style of fix... Thank you.

BTW - I am curious - in your app that exhibits the same crash - what did you do
to work around the problem ? - Is it also running a thread and calling methods
that are normally event driven commands in the main thread?  Or two other
threads like me?  It would be interesting to try to spot any similarities...

Is it even allowed to asynchronously call a main thread method from another
thread? - it seems to work - but I am not sure why it does - what is the main
thread's mainloop doing while this is going on?  - your other comment in the
other thread here implies that it is a strict no - no...  Is it safe to call
invoke from another thread? - what is the difference between calling invoke and
calling the bound method directly?

- Hendrik






More information about the Python-list mailing list