SimpleXMLRPCServer and creating a new object on for each new clientrequest.

J

J

Hi list,

My goals is to have concurrent and separated client sessions using xmlrpc.
Initially my though was that SimpleXMLRPCServer was able to create a new
object instance for each incoming request.
But this doesn't appear to be the case, unless I'm overlooking something,
if so please point me out.

Concider following simplified code


#!/usr/bin/python

from SimpleXMLRPCServer import SimpleXMLRPCServer
from SimpleXMLRPCServer import SimpleXMLRPCRequestHandler
import random

# Restrict to a particular path.
class RequestHandler(SimpleXMLRPCRequestHandler):
rpc_paths = ('/RPC2',)

# Create a simple example class
class Randomizer:
def __init__(self):
self.random=random.randrange(0,100000)
def show_random(self):
return self.random

# Create server
server = SimpleXMLRPCServer(("localhost",
8000),requestHandler=RequestHandler,allow_none=1)
server.register_introspection_functions()

server.register_instance(Randomizer())
server.serve_forever()



I start python interactively:
I though that session1 and session2 would be 2 different Randomizer objects
each having a different result for self.random
But as the example shows this is not the case.
How can I solve this?

Thanks

Jelle
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top