意外的关键字参数';缓冲';-python客户端

意外的关键字参数';缓冲';-python客户端,python,wcf,rest,python-3.x,python-requests,Python,Wcf,Rest,Python 3.x,Python Requests,我收到的错误是“getresponse()得到了一个意外的关键字参数‘buffering’”。完整的错误日志为: [INFO ] Kivy v1.8.0 [INFO ] [Logger ] Record log in C:\Users\Sudheer\.kivy\logs\kivy_14-08-15_21.txt [INFO ] [Factory ] 157 symbols loaded [DEBUG

我收到的错误是“getresponse()得到了一个意外的关键字参数‘buffering’”。完整的错误日志为:

[INFO              ] Kivy v1.8.0
[INFO              ] [Logger      ] Record log in C:\Users\Sudheer\.kivy\logs\kivy_14-08-15_21.txt
[INFO              ] [Factory     ] 157 symbols loaded
[DEBUG             ] [Cache       ] register <kv.lang> with limit=None, timeout=Nones
[DEBUG             ] [Cache       ] register <kv.image> with limit=None, timeout=60s
[DEBUG             ] [Cache       ] register <kv.atlas> with limit=None, timeout=Nones
[INFO              ] [Image       ] Providers: img_tex, img_dds, img_pygame, img_gif (img_pil ignored)
[DEBUG             ] [Cache       ] register <kv.texture> with limit=1000, timeout=60s
[DEBUG             ] [Cache       ] register <kv.shader> with limit=1000, timeout=3600s
[DEBUG             ] [App         ] Loading kv <D:\OS Files\workspace\Assistant\start.kv>
[INFO              ] [Text        ] Provider: pygame
[DEBUG             ] [Cache       ] register <kv.loader> with limit=500, timeout=60s
[INFO              ] [Loader      ] using a thread pool of 2 workers
[DEBUG             ] [Cache       ] register <textinput.label> with limit=None, timeout=60.0s
[DEBUG             ] [Cache       ] register <textinput.width> with limit=None, timeout=60.0s
[DEBUG             ] [Window      ] Ignored <egl_rpi> (import error)
[INFO              ] [Window      ] Provider: pygame(['window_egl_rpi'] ignored)
[DEBUG             ] [Window      ] Display driver windib
[DEBUG             ] [Window      ] Actual window size: 800x600
[DEBUG             ] [Window      ] Actual color bits r8 g8 b8 a0
[DEBUG             ] [Window      ] Actual depth bits: 24
[DEBUG             ] [Window      ] Actual stencil bits: 8
[DEBUG             ] [Window      ] Actual multisampling samples: 2
GLEW initialization succeeded
[INFO              ] [GL          ] OpenGL version <b'3.3.0'>
[INFO              ] [GL          ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO              ] [GL          ] OpenGL renderer <b'GeForce 9400 GT/PCIe/SSE2'>
[INFO              ] [GL          ] OpenGL parsed version: 3, 3
[INFO              ] [GL          ] Shading version <b'3.30 NVIDIA via Cg compiler'>
[INFO              ] [GL          ] Texture max size <8192>
[INFO              ] [GL          ] Texture max units <32>
[DEBUG             ] [Shader      ] Fragment compiled successfully
[DEBUG             ] [Shader      ] Vertex compiled successfully
[DEBUG             ] [ImagePygame ] Load <C:\Kivy180\kivy\kivy\data\glsl\default.png>
[INFO              ] [Window      ] virtual keyboard not allowed, single mode, not docked
[DEBUG             ] [Atlas       ] Load <C:\Kivy180\kivy\kivy\data\..\data\images\defaulttheme.atlas>
[DEBUG             ] [Atlas       ] Need to load 1 images
[DEBUG             ] [Atlas       ] Load <C:\Kivy180\kivy\kivy\data\..\data\images\defaulttheme-0.png>
[DEBUG             ] [ImagePygame ] Load <C:\Kivy180\kivy\kivy\data\..\data\images\defaulttheme-0.png>
[INFO              ] [GL          ] NPOT texture support is available
[INFO              ] [OSC         ] using <thread> for socket
[DEBUG             ] [Base        ] Create provider from mouse
[DEBUG             ] [Base        ] Create provider from wm_touch
[DEBUG             ] [Base        ] Create provider from wm_pen
[INFO              ] [Base        ] Start application main loop
{'DoWorkResult': 'Working'}
http://localhost:9624/BasicServ.svc/auth/Authorize/admin/1234
[INFO              ] [Base        ] Leaving application in progress...
 Traceback (most recent call last):
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\packages\urllib3\connectionpool.py", line 313, in _make_request
     httplib_response = conn.getresponse(buffering=True)
 TypeError: getresponse() got an unexpected keyword argument 'buffering'

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\packages\urllib3\connectionpool.py", line 480, in urlopen
     body=body, headers=headers)
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\packages\urllib3\connectionpool.py", line 315, in _make_request
     httplib_response = conn.getresponse()
   File "C:\Kivy180\Python33\lib\http\client.py", line 1147, in getresponse
     response.begin()
   File "C:\Kivy180\Python33\lib\http\client.py", line 358, in begin
     version, status, reason = self._read_status()
   File "C:\Kivy180\Python33\lib\http\client.py", line 320, in _read_status
     line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
   File "C:\Kivy180\Python33\lib\socket.py", line 297, in readinto
     return self._sock.recv_into(b)
 ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote host

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\adapters.py", line 330, in send
     timeout=timeout
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\packages\urllib3\connectionpool.py", line 530, in urlopen
     raise MaxRetryError(self, url, e)
 requests.packages.urllib3.exceptions.MaxRetryError: HTTPConnectionPool(host='localhost', port=9624): Max retries exceeded with url: /BasicServ.svc/auth/Authorize/admin/1234 (Caused by <class 'ConnectionResetError'>: [WinError 10054] An existing connection was forcibly closed by the remote host)

 During handling of the above exception, another exception occurred:

 Traceback (most recent call last):
   File "D:\OS Files\workspace\Assistant\main.py", line 10, in <module>
     StartApp().run()
   File "C:\Kivy180\kivy\kivy\app.py", line 792, in run
     runTouchApp()
   File "C:\Kivy180\kivy\kivy\base.py", line 481, in runTouchApp
     EventLoop.window.mainloop()
   File "C:\Kivy180\kivy\kivy\core\window\window_pygame.py", line 381, in mainloop
     self._mainloop()
   File "C:\Kivy180\kivy\kivy\core\window\window_pygame.py", line 287, in _mainloop
     EventLoop.idle()
   File "C:\Kivy180\kivy\kivy\base.py", line 324, in idle
     self.dispatch_input()
   File "C:\Kivy180\kivy\kivy\base.py", line 309, in dispatch_input
     post_dispatch_input(*pop(0))
   File "C:\Kivy180\kivy\kivy\base.py", line 220, in post_dispatch_input
     listener.dispatch('on_motion', etype, me)
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:4537)
     return handler(*largs)
   File "C:\Kivy180\kivy\kivy\core\window\__init__.py", line 645, in on_motion
     self.dispatch('on_touch_down', me)
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:4537)
     return handler(*largs)
   File "C:\Kivy180\kivy\kivy\core\window\__init__.py", line 657, in on_touch_down
     if w.dispatch('on_touch_down', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:4537)
     return handler(*largs)
   File "C:\Kivy180\kivy\kivy\uix\widget.py", line 284, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:4537)
     return handler(*largs)
   File "C:\Kivy180\kivy\kivy\uix\widget.py", line 284, in on_touch_down
     if child.dispatch('on_touch_down', touch):
   File "_event.pyx", line 316, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:4537)
     return handler(*largs)
   File "C:\Kivy180\kivy\kivy\uix\behaviors.py", line 93, in on_touch_down
     self.dispatch('on_press')
   File "_event.pyx", line 312, in kivy._event.EventDispatcher.dispatch (kivy\_event.c:4491)
     if handler(self, *largs):
   File "C:\Kivy180\kivy\kivy\lang.py", line 1299, in custom_callback
     exec(__kvlang__.co_value, idmap)
   File "D:\OS Files\workspace\Assistant\start.kv", line 65, in <module>
     on_press: root.Authorization(self,userid.text,password.text)
   File "D:\OS Files\workspace\Assistant\forms.py", line 18, in Authorization
     if self.loginclass.Authorization()== True:
   File "D:\OS Files\workspace\Assistant\classes.py", line 8, in Authorization
     return LoginAccess(self.userid, self.password)
   File "D:\OS Files\workspace\Assistant\dbcodes.py", line 9, in LoginAccess
     response = requests.get('http://localhost:9624/BasicServ.svc/auth/Authorize/'+userid+'/'+password,stream=False)
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\api.py", line 55, in get
     return request('get', url, **kwargs)
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\api.py", line 44, in request
     return session.request(method=method, url=url, **kwargs)
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\sessions.py", line 383, in request
     resp = self.send(prep, **send_kwargs)
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\sessions.py", line 486, in send
     r = adapter.send(request, **kwargs)
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\adapters.py", line 378, in send
     raise ConnectionError(e)
 requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=9624): Max retries exceeded with url: /BasicServ.svc/auth/Authorize/admin/1234 (Caused by <class 'ConnectionResetError'>: [WinError 10054] An existing connection was forcibly closed by the remote host)
第一个响应仅用于测试服务,它正在工作,第二个响应我收到错误。我会为加密和SSL编写代码,但目前正在尝试让rest客户端工作。我还测试了Stream=True和False,但结果是一样的

我在谷歌上搜索了一下,发现这个错误通常和旧的请求模块有关,但我使用的是更新的模块

请求模块为2.2.1 带Kivy的Python 3.3 net 4上的WCF

编辑: WCF Web配置文件:

<?xml version="1.0"?>
<configuration>

  <system.web>
    <compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>
    <services>
      <service behaviorConfiguration="ServBehav" name="AssistantWcf.BasicServ">
        <endpoint address="auth" behaviorConfiguration="EndBehav" binding="webHttpBinding" name="endpointname" contract="AssistantWcf.IBasicServ" />
      </service>
    </services>
    <behaviors>
      <endpointBehaviors>
        <behavior name="EndBehav">
          <webHttp/>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="ServBehav">
          <!-- To avoid disclosing metadata information, set the value below to false before deployment -->
          <serviceMetadata httpGetEnabled="true" httpGetBinding="webHttpBinding" httpGetBindingConfiguration="" />
          <!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
          <serviceDebug includeExceptionDetailInFaults="false"/>
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
    <!--
        To browse web app root directory during debugging, set the value below to true.
        Set to false before deployment to avoid disclosing web app folder information.
      -->
    <directoryBrowse enabled="true"/>
  </system.webServer>

</configuration>

您似乎不熟悉Python 3。它引入了一种新的回溯方式,这样您就可以最好地找出代码的路径,从而有可能找到最终异常的来源。让我们检查一下您的回溯:

 Traceback (most recent call last):
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\packages\urllib3\connectionpool.py", line 313, in _make_request
     httplib_response = conn.getresponse(buffering=True)
 TypeError: getresponse() got an unexpected keyword argument 'buffering'

 During handling of the above exception, another exception occurred:
这里最重要的是最后一行:“在处理上述异常期间,发生了另一个异常:”。这表明
TypeError:getresponse()得到了一个意外的关键字参数“buffering”
不是导致程序停止的异常的来源,但实际上它是在发生不同的异常时被处理的

您现在会注意到,“在处理上述异常的过程中,发生了另一个异常:”在粘贴的输出中再发生几次,最终跟踪以:

File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\adapters.py", line 378, in send
 raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=9624): Max retries exceeded with url:
/BasicServ.svc/auth/Authorize/admin/1234
(Caused by <class 'ConnectionResetError'>:
    [WinError 10054] An existing connection was forcibly closed by the remote host)
文件“C:\Kivy180\Python33\lib\site packages\requests-2.2.1-py3.3.egg\requests\adapters.py”,第378行,在send中 升起连接器错误(e) requests.exceptions.ConnectionError:HTTPConnectionPool(host='localhost',port=9624):url超过了最大重试次数: /BasicServ.svc/auth/Authorize/admin/1234 (原因: [WinError 10054]远程主机已强制关闭现有连接) 我将最后一行拆分为更可读的部分(因此它不会滚动到一边)。您看到的异常是由服务器强制关闭打开的连接引起的。如果您使用的是
会话
对象,我通常会看到这种情况,因为默认情况下,它为您提供连接池,但您使用的是函数式API,每次都会创建一个新的
会话
对象。这意味着,如果这种情况反复发生,这里的服务器很可能会出现异常。服务器拒绝响应您的请求,并强制关闭已建立的连接。在尝试读取响应时,urllib3接收到
WinError
异常,除了提供自己的异常
ConnectionResetError
之外,没有好的恢复方法。然后,请求捕获并引发它自己的
ConnectionError

这里的问题似乎不是请求,而是服务器行为不端



另一方面,在URL中包含用户名和密码是一个非常糟糕的想法。我建议您研究使用HTTP摘要身份验证、HTTP基本身份验证或实现更安全的方法(如基于令牌的身份验证方案)。

谢谢您的回复,是的,我是python新手,我在谷歌上搜索了错误以及所有错误链。我了解到,一般的问题是由于与服务器的连接太多,然而,在我的情况下,它只是一个连接。当第一个rest url工作时,我想另一个相同服务的url也应该工作。你能给我一些建议吗。谢谢您的时间。我不知道
wcf
,所以我无法建议您如何解决该问题。您应该用该代码和问题提出一个不同的问题(不要提及请求,因为它不是问题的一部分)。您应该提到,您可以
获取第一个URL,但不能获取第二个URL,并且在尝试获取第二个URL时,服务器会意外关闭连接。在这个问题上你会得到更好的帮助。我们也添加了WCF标签,所以我认为这个问题可以保持开放,而且,就我所知,根据你的想法,WCF代码是正确的,为了安全起见,我也会在问题中添加WCF web配置。@surpavan我建议您提出一个单独的问题,这个问题会更直接,并且肯定会吸引那些能够帮助您的人的注意。现在,每个阅读标题的人都希望这是关于Python中的一个bug,但事实并非如此。好的,我将打开一个新问题,只是等了一会儿,看看是否有其他人可以回答。非常感谢。
 Traceback (most recent call last):
   File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\packages\urllib3\connectionpool.py", line 313, in _make_request
     httplib_response = conn.getresponse(buffering=True)
 TypeError: getresponse() got an unexpected keyword argument 'buffering'

 During handling of the above exception, another exception occurred:
File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\adapters.py", line 378, in send
 raise ConnectionError(e)
requests.exceptions.ConnectionError: HTTPConnectionPool(host='localhost', port=9624): Max retries exceeded with url:
/BasicServ.svc/auth/Authorize/admin/1234
(Caused by <class 'ConnectionResetError'>:
    [WinError 10054] An existing connection was forcibly closed by the remote host)