Tkinter, asyncore - Two questions

Rune Hansen rune.hansen at vivenus.no
Tue May 14 10:36:19 EDT 2002


Hello, I've written an Tkinter application that uses asyncore to
connect to a streaming server.

This is the code for the asyncore loop:

        if[....]    
            self.sc = 
client(host[0],int(port[0]),self,self.readPasswordFile())
            self.poll()
        else:
            print "could not find configuration file"

    
    def poll(self):
        try:
            asyncore.poll(0.05)
            self.master.after(100, self.poll)
        except:
            #Logg errrors ? print "Poll Failed.."
            #print to status area ?
            pass


My question is : The poll() function: is
this the "right" way to do this? I believe that I've read a news post
from Fredrik Lundh where he stated that the above might not be the best way
to do this..without references to the "right" way of course:-)

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.

I've not included any code from the asyncore class since it's alomost
identical to the snipplet in the modules documentation.

regards

/rune 
-- 
Rune Hansen
rune.hansen at viventus.no

"Engineering does not require science. Science helps a lot but people
built perfectly good brick walls long before they knew why cement works."
--Allan Cox



More information about the Python-list mailing list