Am I doing something wrong? It seems that I shouldn't call
_display() so happily...
You are not doing anything wrong, as long as your _display()
function doesn't take too much time to return (which is a
purely qualitative criteria, largely depending of the
desklet).
Let me explain briefly: a desklet written in python is at
least composed of two process: a driving python interpreter,
executing the desklet script, and a self-contained adesklets
interpreter that performs all the graphical operations. When
a user interactively selects the
Quit option from the contextual menu, the
adesklets interpreter exits right away, notifying the python
process (sending back a
quit
event to it).
What happens in your case is that all events notifications
are blocked by default during the execution of any event that
is not alarm(); therefore, trying to continue sending
commands to the adesklets interpreter results in a
"
adesklets process exited"
exception, which is perfectly right and fine.
How can I tell if it is safe to call it?
You cannot know, unless it happens: it is the whole point of
raising an exception. User manually killing a desklet is an
exceptional, asynchronous event (normally, people do not quit
desklets this way very often: hence it would be very wasteful
to check for this all the time). Of course, nothing prevents
you from catching the exception and handling things in a less
"console-noisy" way. Most of the time, there is little use
doing so (and I personally never did), since most of desklets
do not handle any persistent information in a way that would
interleave generating graphic output and modifing the data...
Yours,