SocketServer, handle(), and scope

Foo J. Bar foobar at foo.com
Sun Feb 6 04:12:20 CET 2000


I'm using the SocketServer module for a
a ThreadingTCPServer.  I created a
new class that had an override for the
handle function. This all works fine
and my client does indeed connect to and
send messages to the server without any
problems.  However, my problem is that
my program is running a fairy large application
where the user has an interactive session
with the Python interpreter.  He/she types:

---------------------------------
# foo.py contains a fairly large class Bar

import foo,time

a = foo.Bar()
a.start_large_application()

a.rate = 30

def doit():
  while 1:
     a.send_message()
     time.sleep(1.0/a.rate)


# myhandler.py contains a class that 
# overrides the handle function

import SocketServer,thread
from myhandler import Myhandler

myserver=SocketServer.ThreadingTCPServer(('',4444),Myhandler)
thread.start_new(myserver.serve_forever,())

doit()
-----------------------------       

I need to be able to change this value ('a.rate') from 
a remote workstation (hense the need for my application to
run a server (SocketServer). 

How should I do this?  How does one design (or use) the
handle function (or Myhandle class) so that information
can be shared between classes (or changed in the scope 
the user is running in).

Any advice (or pointers to existing code) would be
greatly appreciated.

Thanks,
Sam



More information about the Python-list mailing list