473,890 Members | 5,841 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SimpleXMLRPCSer ver and Threading

Hi,

is SimpleXMLRPCSer ver multithreaded or how does it handle multiple
clients? I want to implement a simple server which will be queried by
multiple processes for work to be done. The server will simply hold a
queue with files to process. The clients will ask for the next file.

Do I have to sync access to the queue or is the server not threaded at all?

regards,
Achim
Mar 28 '07 #1
3 7256

"Achim Domma" <do***@procoder s.netwrote in message
news:46******** *************** @newsspool3.arc or-online.net...
Hi,

is SimpleXMLRPCSer ver multithreaded or how does it handle multiple
clients? I want to implement a simple server which will be queried by
multiple processes for work to be done. The server will simply hold a
queue with files to process. The clients will ask for the next file.

Do I have to sync access to the queue or is the server not threaded at
all?
I don't claim to know much about the internals of the module, but it
imports BaseHTTPServer which I am sure is multithreaded. I did not test
this with functions, but when you register an object in the server,
different clients are accessing the same object:
(The following example is modified from that given in the module
documentation: http://docs.python.org/lib/module-Si...RPCServer.html)
$ cat server.py
#!/usr/bin/env python

from SimpleXMLRPCSer ver import SimpleXMLRPCSer ver

# Create server
server = SimpleXMLRPCSer ver(("localhost ", 8000))
server.register _introspection_ functions()

# Register pow() function; this will use the value of
# pow.__name__ as the name, which is just 'pow'.
server.register _function(pow)

# Register a function under a different name
def adder_function( x,y):
return x + y
server.register _function(adder _function, 'add')
# Register an instance; all the methods of the instance are
# published as XML-RPC methods (in this case, just 'div').
class MyObj:
SEQ = None

def __init__(self):
self.SEQ = range(10000)
self.index = 0

def next_seq(self):
n = self.SEQ[self.index]
self.index += 1
return n

server.register _instance(MyObj ())

# Run the server's main loop
server.serve_fo rever()
# First client calls:
>>import xmlrpclib
url = 'http://localhost:8000'
s = xmlrpclib.Serve r(url)
s.next_seq( )
0
>>s.next_seq( )
1
>>s.next_seq( )
2
# second client calls
>>import xmlrpclib
url = 'http://localhost:8000'
s = xmlrpclib.Serve r(url)
s.next_seq( )
3
I did not programmaticall y drive these calls at the same time to try to
force simultaneous access from separate requests, but my intuition is that
it's a pretty good bet that SimpleXMLRPCSer ver has taken care of re-entrant
issues. It may be instructive for you to run that test yourself and
explicitly verify requests do not interact.

Alternatively, if you really want to know for sure... Python is an
open-source project. You can dig around in SimpleXMLRPCSer ver.py yourself
and figure out exactly what it is doing:
>>import SimpleXMLRPCSer ver
SimpleXMLRPCS erver
<module 'SimpleXMLRPCSe rver' from
'/usr/lib/python2.4/SimpleXMLRPCSer ver.pyc'>
>>>
ej@myBox ~
$ vi /usr/lib/python2.4/SimpleXMLRPCSer ver.py

see also:
http://docs.python.org/lib/module-BaseHTTPServer.html
http://docs.python.org/lib/module-SocketServer.html


Mar 28 '07 #2
This is off of memory so I apologize if I don't get all of the details right.

The base SimpleXMLRPCSer ver uses TCPServer as it's server component
and SimpleXMLXMLRPC RequestHandler as it's handler. The handler is a
subclass of BaseHTTPRequest Handler, which itself doesn't handle any
multithreading. You need to use one of the *MixIn classes if you want
to handle concurrent requests.

-Jeff
On 3/28/07, Erik Johnson <no****@invalid .comwrote:
>
"Achim Domma" <do***@procoder s.netwrote in message
news:46******** *************** @newsspool3.arc or-online.net...
Hi,

is SimpleXMLRPCSer ver multithreaded or how does it handle multiple
clients? I want to implement a simple server which will be queried by
multiple processes for work to be done. The server will simply hold a
queue with files to process. The clients will ask for the next file.

Do I have to sync access to the queue or is the server not threaded at
all?
I don't claim to know much about the internals of the module, but it
imports BaseHTTPServer which I am sure is multithreaded. I did not test
this with functions, but when you register an object in the server,
different clients are accessing the same object:
(The following example is modified from that given in the module
documentation: http://docs.python.org/lib/module-Si...RPCServer.html)
$ cat server.py
#!/usr/bin/env python

from SimpleXMLRPCSer ver import SimpleXMLRPCSer ver

# Create server
server = SimpleXMLRPCSer ver(("localhost ", 8000))
server.register _introspection_ functions()

# Register pow() function; this will use the value of
# pow.__name__ as the name, which is just 'pow'.
server.register _function(pow)

# Register a function under a different name
def adder_function( x,y):
return x + y
server.register _function(adder _function, 'add')
# Register an instance; all the methods of the instance are
# published as XML-RPC methods (in this case, just 'div').
class MyObj:
SEQ = None

def __init__(self):
self.SEQ = range(10000)
self.index = 0

def next_seq(self):
n = self.SEQ[self.index]
self.index += 1
return n

server.register _instance(MyObj ())

# Run the server's main loop
server.serve_fo rever()
# First client calls:
>import xmlrpclib
url = 'http://localhost:8000'
s = xmlrpclib.Serve r(url)
s.next_seq()
0
>s.next_seq()
1
>s.next_seq()
2
# second client calls
>import xmlrpclib
url = 'http://localhost:8000'
s = xmlrpclib.Serve r(url)
s.next_seq()
3
I did not programmaticall y drive these calls at the same time to try to
force simultaneous access from separate requests, but my intuition is that
it's a pretty good bet that SimpleXMLRPCSer ver has taken care of re-entrant
issues. It may be instructive for you to run that test yourself and
explicitly verify requests do not interact.

Alternatively, if you really want to know for sure... Python is an
open-source project. You can dig around in SimpleXMLRPCSer ver.py yourself
and figure out exactly what it is doing:
>import SimpleXMLRPCSer ver
SimpleXMLRPCSe rver
<module 'SimpleXMLRPCSe rver' from
'/usr/lib/python2.4/SimpleXMLRPCSer ver.pyc'>
>>

ej@myBox ~
$ vi /usr/lib/python2.4/SimpleXMLRPCSer ver.py

see also:
http://docs.python.org/lib/module-BaseHTTPServer.html
http://docs.python.org/lib/module-SocketServer.html


--
http://mail.python.org/mailman/listinfo/python-list
Mar 29 '07 #3
Jeff McNeil wrote:
This is off of memory so I apologize if I don't get all of the details right.

The base SimpleXMLRPCSer ver uses TCPServer as it's server component
and SimpleXMLXMLRPC RequestHandler as it's handler. The handler is a
subclass of BaseHTTPRequest Handler, which itself doesn't handle any
multithreading. You need to use one of the *MixIn classes if you want
to handle concurrent requests.
Does it mean that, if I subclass from ThreadingMixIn then my exported
functions will be called from different threads? I created many multi
threaded servers, based on TCPServer, but I'm not sure about
XMLRPCServer. I used to create my own handler class and in that case, a
new handler instance was created for each request, then a new thread was
created and handle_request was called from that new thread. I guess that
in this case, a new SimpleXMLXMLRPC RequestHandler is created for each
request and a new thread is started.... but I'm not sure. Please help us
out.

By the way, we should have __server__ examples in the documentation of
xmlrpclib, right? What is the right way of contributing an example?

Best,

Laszlo

Mar 29 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
4812
by: Marco Aschwanden | last post by:
I would like to develop a server based on python's xmlrpc. But I realized that SimpleXMLRPCServer does not spawn a thread for each request. How could the SimpleXMLRPCServer be turned into a multi-threaded Server? Is there a reason why the SimpleXMLRPCServer is not multi-threaded? Is there a plan to make it multi-threaded? Thanks for any hints in advance,
0
1290
by: danu kusmana | last post by:
Hi Im trying to figure out why the same server script I use is running slower in Windows than in Linux. ServerTest.py: #! /usr/bin/env python import SocketServer
9
785
by: Yannick Turgeon | last post by:
I plan to use XML-RPC to communicate between my python server and VB client. I just called a simple registered function (lambda x,y: x+y) and it worked. But I'm new to XML-RPC and I'm now wondering why this class is called "Simple". What are its limitations? I want to know if I can count on it for my project or if I would need a not-so-simple XML-RPC server. Yannick
4
2345
by: codecraig | last post by:
Hi, I thought I posted this, but its been about 10min and hasnt shown up on the group. Basically I created a SimpleXMLRPCServer and when one of its methods gets called and it returns a response to the client, the server prints some info out to the console, such as, localhost - - "POST /RPC2 HTTP/1.0" 200 - Anyhow, is there a way I can surpress that so its not printed to the
0
1194
by: Thomas G. Apostolou | last post by:
Hello all, I use Python 2.3.3 and try to patch SimpleXMLRPCServer.py with the patch i got from Python.org. so after changing to the directory where both SimpleXMLRPCServer.py and SimpleXMLRPCServer.patch reside i run : patch -i SimpleXMLRPCServer.patch -b --verbose --dry-run SimpleXMLRPCServer.py and i get : Hmm...patch: **** unexpected end of hunk at line 47
0
2010
by: JDF | last post by:
I am trying to create a Windows service using SimpleXMLRPCServer and win32serviceutil. The service itself seems to be working properly (starts, stops, etc) and I can connect using an XMLRPC client from the localhost. However when I connect from a remote client, I either get a socket error or an xmlrpclib.ProtocolError error. If I use serve_forever() rather than handle_request(), the remote clients can connect but it breaks the Windows...
0
1228
by: Juju | last post by:
Hi, First, sorry for my poor English ! I used the SimpleXMLRPCServer facility of Python to develop a multithread-server, here's part of my code : -- class TotoSimpleXMLRPCServer(SocketServer.ThreadingMixIn, SimpleXMLRPCServer.SimpleXMLRPCServer):
2
2334
by: Vyacheslav Maslov | last post by:
Hi, all! I need multi threaded version of SimpleXMLRPCServer. Does python library already have implementation of this one? Or i need to implement multi threading by myself? Which way is the simpliest?
9
3281
by: Bret | last post by:
I'm coming back to Python after an absence and it's surprising how many things I've forgotten since wandering (against my will) into Java land. Anyway, I have a need for a way to make SimpleXMLRPCServer interruptable. Basically, I have a main server that, in response to certain RPC calls, creates additional servers on different ports. I then need to be able to shut these additional servers down. I've got something like this in the...
0
9979
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
11234
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10827
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9637
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
7170
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5854
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4681
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
4275
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3281
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.