Hi,
On Saturday, September 27, 2014 11:19:50 PM UTC+1, vana...@ucar.edu wrote:I’m very new to python-pulsar, so please bear with me.I'm trying to use the Twisted compatibility mode of pulsar, since this
is the only way I know of to get a XML-RPC server running under
asyncio.To write a XML-RPC server for asyncio shouldn't be too difficult when using pulsar.Pulsar has a JSON-RPC wsgi middleware which is not dissimilar.All you need is a XMLRPC class inheriting from RpcHandler and implement the callable method.
from pulsar.apps.rpc import RpcHandler
class XMLRPC(RpcHandler):
def __call__(self, request):
...I'm happy to help you out if you decide to go for this solution.Once you have the XMLRPC handler you can write your application like
from pulsar.apps import wsgi
class MyRpc(XMLRPC):
def rpc_add(self, request, a, b):
return a+b
class Wsgi(wsgi.LazyWsgi):def handler(self, environ=None):app = wsgi.Router('/', post=MyRpc())return wsgi.wsgiHandler([app])if __name__ == '__main__':wsgi.WsgiServer(Wsgi()).start()If you want to re-use twisted implementation you can try with pulsar.apps.tx as you mentioned but I'm not sure it will work.
If I comment out the following lines:
from pulsar.apps.tx import tx
This is a crucial import. It replaces the the twisted reactor with a proxy to the asyncio event loop.If you don't use it you are not using asyncio but twisted instead.
from pulsar.utils.log import process_globalYou don't need this import
and add a reactor.run() call to main(), the script runs my XML-RPC
server, with repeated calls to 'doPoll()', as I expect.reactor.run is switched off by pulsar when importing tx.To run the event loop you either use a pulsar application as above or asyncio directlyasyncio.get_eventloop().run_forever()2) If have two different files in my application that both import pulsar.apps.tx, won’t this cause two calls to _reactor.run()?Yes but reactor.run does nothing as previously mentioned.--
You received this message because you are subscribed to the Google Groups "python-pulsar" group.
To unsubscribe from this group and stop receiving emails from it, send an email to python-pulsa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Hello!I hope it's okay to hijack this thread, as with regards to asyncio, I'd like to ask about uWSGI support (it has asyncio [tulip?] support http://uwsgi-docs.readthedocs.org/en/latest/asyncio.html and support for various other async event loops http://uwsgi-docs.readthedocs.org/en/latest/Async.html ). Or maybe uWSGI is unnecessary, pulsar's implementation is performant and capable enough?
Also, would you recommend putting anything in front of pulsar for "production" deployments? (nginx? or they muck up latency because of potentially buffering the incoming requests?)