问题
I'm looking at spyne to be able to make a webservice that handles requests in json. The problem is that I still didn't managed to get it working for more than one request at a time.
I thought this https://github.com/arskom/spyne/blob/master/examples/async.py might solve, but I can't seem to make it work as the get_callback_info() isn't found anywhere... Does anyone know any example of how to handle multiple requests at the same time with spyne? Thanks!
回答1:
You mean you can't get Spyne to be concurrent? That has nothing to do with Spyne, it's the transport's job to implement concurrency.
I assume you refer to the examples that use wsgiref, the reference WSGI implementation, which doesn't support concurrency. Good news is, Spyne can be and is being used as concurrently as any Python daemon can be.
You can use twisted in async mode with TwistedWebResource
or in sync mode with WSGIApplication
. You can find the relevant examples in examples/twisted
directory in resource.py
and wsgi.py
respectively.
If twisted scares you (For some reason, it's got a totally baseless "not for the faint-hearted" kind of reputation) you can use cherrypy. I just put a cherrypy wsgi example in examples/cherry
directory.
来源:https://stackoverflow.com/questions/30824038/spyne-receiving-multiple-requests