integrating SocketServer with Tkinter Event-Loop

Peter Funk pf at artcom-gmbh.de
Tue Oct 19 17:13:49 EDT 1999


Fredrik Lundh wrote:
> > I want to write a Python application with a Tkinter based GUI which
> > serves incoming requests using a SocketServer in the same process at the
> > same time.  I am trying to use the standard lib module 'asyncore' for 
> > this purpose.
> 
> whoa!  does this really work?

At least the tiny example server I posted to comp.lang.python works as 
I expected it to do. 

I've tested it here only locally with Py1.5.2/SuSE Linux.  
And yes: it was possible to request files from it using the URL
'http://localhost:8080/xmlrpclib.py' (with xmlrpclib.py being an
arbitrary not so small file living in the same directory, where I 
started the example server program).

Indeed I have downloaded your fine xmlrpc library and have a more
elaborated test application with a Tkinter GUI and an integrated
xml-rpc server.  I plan to use xml-rpc as some kind of easy to use
remote control interface to my application, which does simulate a
virtual cylinder engraving machine.

> (cannot really tell if your post is a question
> or not, but I definitely wouldn't have done
> it that way...  and I don't understand how
> it can work -- after all, doesn't the Socket-
> Server stuff assume blocking sockets?)

Well: the asyncore 'poll()' uses 'select' and so internally asserts that 
the socket is ready to read at the time, when xmlrpcserver.RequestHandler
gets called by SocketServer.TCPServer.handle_request.  I wasn't able to 
figure out, where the non blocking socket would play havoc to the code
in 'SocketServer.py' ...  :-(
I was afraid, that it wouldn't be that easy. :-(

Do you have any better suggestions how to accomplish, what I want?

Regards from Germany and many thanks for your good work, Peter Funk
-- 
Peter Funk, Oldenburger Str.86, 27777 Ganderkesee, Tel: 04222 9502 70, Fax: -60




More information about the Python-list mailing list