简体   繁体   English

Django 1.4中是否设置了任何超时?

[英]Is there any timeout set in Django 1.4?

I have got an issue with Django 1.4 and with Soaplib 2.0. 我在Django 1.4和Soaplib 2.0中遇到了问题。

When I send from my client a request with some large arguments, Django raised an exception and send an email of this type : " [Django] ERROR (EXTERNAL IP): Internal Server Error: /uri/to/soap/service " 当我从客户端发送带有一些大参数的请求时,Django引发异常并发送以下类型的电子邮件:“ [Django]错误(外部IP):内部服务器错误:/ uri / to / soap / service

Traceback (most recent call last):
File "/path/to/my/project/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 129, in get_response
raise ValueError("The view %s.%s didn't return an HttpResponse object." % (callback.__module__, view_name))

ValueError: The view myproject/library.soap.wsgi.view didn't return an HttpResponse object.

I use the normal @soap decorator available at http://soaplib.github.io/soaplib/2_0/pages/helloworld.html#declaring-a-soaplib-service on the server side. 我使用服务器端http://soaplib.github.io/soaplib/2_0/pages/helloworld.html#declaring-a-soaplib-service上的常规@soap装饰器。

So, it looks like this on the server configuration : 因此,在服务器配置上看起来像这样:

inside urls.py : 里面urls.py

from myproject.server.webservice import WebService

application_view = Application([WebService], 'ws', name='ws').as_django_view()

urlpatterns = patterns(
     url(r'^soap/.*', csrf_exempt( application_view )),
)

inside myproject/server/webservice.py : myproject / server / webservice.py中

 from soaplib.core.service import DefinitionBase
 class WebService(DefinitionBase):
     '''
     The actual webservice class.
     This defines methods exposed to clients.
     '''
     def __init__(self, environ):
         '''
         This saves a reference to the request environment on the current instance
         '''
         self.environ = environ
         super(WebService, self).__init__(environ)

     @soap(Array(Array(String)), _returns=Integer)
     def my_method(self, params):
         return self.process(params)

     def process(self, params):
         #DO SOMETHING HERE

On the client side : 在客户端

 #cfg is my configuration file
 #params is a dictionary 
 client = SoapClient(
                location = cfg.location,
                action = cfg.action, # SOAPAction
                namespace = cfg.namespace, #"http://example.com/sample.wsdl",
                soap_ns= cfg.soap_ns,
                trace = cfg.trace,
                ns = cfg.ns)
 response = client.my_method(params=params)

I have tried to send very large dictionary from my client and it does not work. 我试图从客户端发送非常大的词典,但是它不起作用。

I suspect Django to set a timeout and to close my connection during the process. 我怀疑Django在此过程中设置了超时并关闭了我的连接。 Is there anyway to increase the timeout or is the problem caused by something else ? 是否有增加超时或其他原因导致的问题?

By the way, I use Django only. 顺便说一句,我只使用Django。 I did not configure any Apache or Nginx. 我没有配置任何Apache或Nginx。

Your process(self, params) method does not do anything (in fact as it is currently it's not even valid python because a method needs to have a least one line of code after the signature). 您的process(self, params)方法不执行任何操作(事实上,由于它在签名后至少需要一行代码,因此实际上它甚至不是有效的python)。 You should return some values there which can be used to create a valid soap response. 您应该在那里返回一些值,这些值可用于创建有效的肥皂响应。

As a side note I'd recommend not using soaplib anymore. 附带说明一下,我建议不要再使用soaplib。 It goes supersided by rpclib which in turn is now called spyne. 它由rpclib取代,而rpclib现在又被称为spyne。 Also there are other soap server libraries available which focus more on the SOAP part (eg pysimplesoap, soapfish). 另外,还有其他肥皂服务器库可用,它们更多地关注于SOAP部分(例如pysimplesoap,soapfish)。 I found that helpful because there tend to be less abstractions in between the SOAP xml and the actual implementation. 我发现这很有用,因为SOAP xml与实际实现之间的抽象往往较少。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM