[email protected]
[Top] [All Lists]

Re: [Medusa-dev] async question

Subject: Re: [Medusa-dev] async question
From: Tim Smith
Date: Fri, 08 May 2009 08:24:21 -0400
medusa, and asyncore in general all operates in a single thread of

This does not fit super well with XMLRPC servers that have long running
functions exposed, as a long running function will block other requests.

It can be possible to have multiple threads, each running an asyncore
loop, then the "server" would have to dispatch an incoming socket to a
random asyncore loop to finish the execution.  This would then allow
multiple clients to execute long running functions at the same time,
however if you need a separate thread for every possible client, this
defeats the purpose of medusa and you might as well use a threaded
XMLRPC server

In general, i would only advise using medusa for XMLRPC if you are also
using it for HTTP or other highly asynchronous transport protocols (in
order to add an XMLRPC interface to your server, however the XMLRPC
functions will now have the potential to block other requests)

If you are only offering XMLRPC, best go with a threaded server to
reduce blocking when long running functions are executed.

 -- Tim

lluis gomez i bigorda wrote:
> hello all,
> i'm justr trying to setup a simple server using medusa but I think I'm
> doing something wrong cause it's not async at all ::
> my script is something like this ::
> from socket import gethostname
> from medusa.xmlrpc_handler import xmlrpc_handler
> from medusa.http_server import http_server
> import asyncore
> class xmlrpc_server(xmlrpc_handler):
>     # initialize and run the server
>     def __init__(self, host=None, port=8182):
>         if host is None:
>             host = gethostname( )
>         hs = http_server(host, port)
>         hs.install_handler(self)
>         asyncore.loop( )
>     # an example of a method to be exposed via the XML-RPC protocol
>     def add(self, op1, op2):
>         return op1 + op2
>     # an infinite loop
>     def  (self, op1, op2):
>         while (op1>2):
>                 op1 = op2
>         return False
>     # the infrastructure ("plumbing") to expose methods
>     def call(self, method, params):
>         print "calling method: %s, params: %s" % (method, params)
>         if method == 'add':
>             return self.add(*params)
>         if method == ' ':
>             return self. (*params)
>         return "method not found: %s" % method
> if __name__ == '__main__':
>     server = xmlrpc_server( )
> ok ... the server works but if one client call the procedure " "
> the server will not attend any other petiotions  ...
> can anybody explain what i'm missing please?
> thank you very much in advance,
> ll.
> _______________________________________________
> Medusa-dev mailing list
> [email protected]
> http://mail.python.org/mailman/listinfo/medusa-dev

Medusa-dev mailing list
[email protected]

<Prev in Thread] Current Thread [Next in Thread>