Spyne receiving multiple requests

三世轮回 提交于 2021-01-01 07:13:41

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!