Python简单spyne SOAP web服务响应速度慢

2024-06-28 11:12:19 发布

您现在位置:Python中文网/ 问答频道 /正文

我使用spyne在Python中创建了一个非常简单的SOAP wsgi Web服务器,它只有一个returnint()服务:

from spyne.protocol.soap import Soap11
from spyne.server.wsgi import WsgiApplication
from wsgiref.simple_server import make_server

class TestService(ServiceBase):
    @rpc( _returns=Integer)
    def returnint(self):
        return 1

application = Application([TestService], 'return.int.soap',
                          in_protocol=Soap11(validator='lxml'),
                          out_protocol=Soap11())

if __name__ == '__main__':
    server = make_server('127.0.0.1', 8000, wsgi_application)
    server.serve_forever()

我正在使用肥皂水测试服务,如下所示:

from suds.client import Client

client = Client("http://localhost:8000/?wsdl")
while True:
    result = client.service.returnint()
    print(result)

这似乎工作正常(调用服务时返回1),但是,我面临的问题是,客户端似乎每2秒收到一次响应。是否有人知道这一延迟背后的原因,以及是否有任何方法可以消除它?如果这是不可能的,我将非常感谢任何意见,关于适当的替代品。 


Tags: fromimportclientwsgimakereturnserverapplication