Tkinter, asyncore - Two questions

Van Gale cgale1 at cox.net
Wed May 15 06:01:59 EDT 2002


Rune Hansen wrote:

> Question number two. I'm unable to catch any errors in the asyncore
> loop. Before and during connection I can get error messages from the
> socket object. But I've found no way to get error messages from the
> class after the connection is established. If I remove the network
> connection and try to update the stream or post to the socket nothing
> happens. When I reconect the network my application just continues to
> serve like nothing has happened. This is of course nice, but I had
> hoped to get an error of some kind so that I could tell the user that
> the service is unavailible.

You need to override the handle_error() method of the asyncore base class.
The base class method sends a compact stack trace to the log_info() method,
which just does a print.  Logging in general might be useful to you, so you
might also want to override the log_info() method.

If you want the asyncore.loop to break on an exception (don't do this on
server side!), just do something like this:

def handle_error (self):
    raise

Van






More information about the Python-list mailing list