471,310 Members | 1,096 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,310 software developers and data experts.

Want a strange XML RPC server


Hi,

I would like to have a strage XML RPC server. It should use one main
thread for all connections.

I have some code like this (using a custom RPC server class):
server_address = (LISTEN_HOST, LISTEN_PORT) # (address, port)
server = mess.SecureXMLRPCServer.SecureXMLRPCServer(
server_address,
RequestHandler,
KEYFILE,CERTFILE,
allow_none=True,
logger =
servicelog.getLogger('SecureXMLRPCServer',filename =LOGFILENAME),
logRequests=False,
stop_requested = stop_requested
)
rpcserver = RPCServer() # Object containing public RPC methods.
server.register_instance(rpcserver)

It works perfectly.

Now here is the tricky part. I would like to send back events. It is
implemented by an RPC callback:

#1. client calls server.get_event()
#2. server waits until the event happens (or until a given timeout)
#3. server returns the event (if any)

The clients are running on multiple threads, and the idea is that any
client can send an event by calling server.send_event(event).

That event will be returned to another client by the server. Since the
clients are blocking (waiting for the RPC call to return), events will
go from one client to another immediatelly (through the rpc server).
This goes through different kinds of proxies, and can be used from
different programming languages (Python and PHP clients, in my case...)

The problem is that in #2, waiting for the event to happen inside the
RPC server's handler method will block all other connections to the RPC
server.

Preferred solution: The get_event() method should run in a different
thread inside the server, and return the event to its xmlrpc client from
that thread. However, all other methods should use one main thread. I
would like to implement this as a decorator like:
class RPCServer(object):
"""Object containing public RPC methods."""
def method1(self,arg1):
.....
def method2(self,arg1):
.....
def method3(self,arg1):
.....

@nonblocking
def get_event1(self):
try:
# Wait for 10 seconds until an event is available.
return self.asinharvester.queued_events1.get(True,10)
except Queue.Empty:
return None # Indicates that there was no queued event.

@nonblocking
def get_event2(self):
try:
# Wait for 10 seconds until an event is available.
return self.asinharvester.queued_events2.get(True,10)
except Queue.Empty:
return None # Indicates that there was no queued event.
Is this possible? I have no idea how to write this "nonblocking" decorator.

Thanks,

Laszlo

Jan 8 '08 #1
0 920

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Grzegorz Kaczor | last post: by
14 posts views Thread by Jim Hubbard | last post: by
reply views Thread by Daniel Reber | last post: by
reply views Thread by Grzegorz Kaczor | last post: by
5 posts views Thread by Developer.Man4 | last post: by
3 posts views Thread by Shelly | last post: by
8 posts views Thread by =?Utf-8?B?R2Vvcmdl?= | last post: by
3 posts views Thread by Tomasz J | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.