unexpected keyword argument buffering - python client

2024/10/8 10:49:12

I am receiving the error as "getresponse() got an unexpected keyword argument 'buffering'". Complete error log is :

[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_requesthttplib_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 urlopenbody=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_requesthttplib_response = conn.getresponse()File "C:\Kivy180\Python33\lib\http\client.py", line 1147, in getresponseresponse.begin()File "C:\Kivy180\Python33\lib\http\client.py", line 358, in beginversion, status, reason = self._read_status()File "C:\Kivy180\Python33\lib\http\client.py", line 320, in _read_statusline = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")File "C:\Kivy180\Python33\lib\socket.py", line 297, in readintoreturn self._sock.recv_into(b)ConnectionResetError: [WinError 10054] An existing connection was forcibly closed by the remote hostDuring 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 sendtimeout=timeoutFile "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\packages\urllib3\connectionpool.py", line 530, in urlopenraise 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 runrunTouchApp()File "C:\Kivy180\kivy\kivy\base.py", line 481, in runTouchAppEventLoop.window.mainloop()File "C:\Kivy180\kivy\kivy\core\window\window_pygame.py", line 381, in mainloopself._mainloop()File "C:\Kivy180\kivy\kivy\core\window\window_pygame.py", line 287, in _mainloopEventLoop.idle()File "C:\Kivy180\kivy\kivy\base.py", line 324, in idleself.dispatch_input()File "C:\Kivy180\kivy\kivy\base.py", line 309, in dispatch_inputpost_dispatch_input(*pop(0))File "C:\Kivy180\kivy\kivy\base.py", line 220, in post_dispatch_inputlistener.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_motionself.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_downif 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_downif 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_downif 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_downself.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_callbackexec(__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 Authorizationif self.loginclass.Authorization()== True:File "D:\OS Files\workspace\Assistant\classes.py", line 8, in Authorizationreturn LoginAccess(self.userid, self.password)File "D:\OS Files\workspace\Assistant\dbcodes.py", line 9, in LoginAccessresponse = 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 getreturn request('get', url, **kwargs)File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\api.py", line 44, in requestreturn 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 requestresp = 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 sendr = adapter.send(request, **kwargs)File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\adapters.py", line 378, in sendraise 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)

My related wcf service code is :

<OperationContract()><WebGet(UriTemplate:="Authorize/{id}/{pw}", BodyStyle:=WebMessageBodyStyle.Wrapped, RequestFormat:=WebMessageFormat.Json, ResponseFormat:=WebMessageFormat.Json)>Function Authorize(ByVal id As String, ByVal pw As String)Function Authorize(ByVal id As String, ByVal pw As String) Implements IBasicServ.AuthorizeDim c As New List(Of Guid)For i = 0 To 10c.Add(Guid.NewGuid)NextReturn cEnd Function

The code in python client is :

import requests
import jsondef LoginAccess(userid, password):response = requests.get('http://localhost:9624/BasicServ.svc/auth/test/')print (response.json())print('http://localhost:9624/BasicServ.svc/auth/Authorize/'+userid+'/'+password)response = requests.get('http://localhost:9624/BasicServ.svc/auth/Authorize/'+userid+'/'+password,stream=False)print (response.json())

The first reponse is for testing service only, and it is working, the second one I am receiving the error. I would duly code for encryption and SSL, but currently trying to get that rest client working. I also tested with Stream= True and False, but the result is the same.

I googled on it and found that error would generally be related to requests module being old, but I am using updated one.

Requests module is 2.2.1 Python 3.3 with Kivy WCF on .net 4

EDIT: WCF Web Config File:

<?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>
Answer

You seem to be unfamiliar with Python 3. It introduced a new style of tracebacks so that you can best figure out which path through your code was taken so you can potentially find the source of the final exception. Let's examine your traceback:

 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_requesthttplib_response = conn.getresponse(buffering=True)TypeError: getresponse() got an unexpected keyword argument 'buffering'During handling of the above exception, another exception occurred:

The important thing here is the very last line: "During handling of the above exception, another exception occurred:". This indicates that TypeError: getresponse() got an unexpected keyword argument 'buffering' was not the source of the exception that stopped your program, but it was in fact being handled when a different exception occurred.

You'll now notice that "During handling of the above exception, another exception occurred:" occurs a few more times in the output you pasted and the final trace ends with:

File "C:\Kivy180\Python33\lib\site-packages\requests-2.2.1-py3.3.egg\requests\adapters.py", line 378, in sendraise 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)

I've broken up this last line to be more readable (so it doesn't scroll off to the side). The exception you're seeing is caused by the server forcibly closing a connection that was open. I would normally expect to see this if you were using a Session object because that does connection pooling for you by default, but you're using the functional API which creates a new Session object each time. This means that the server here is most likely misbehaving if this is happening repeatedly. The server is refusing to respond to your request and forcibly closing the connection that was made. While trying to read the response urllib3 receives the WinError exception from which there is no good way to recover other than providing it's own exception ConnectionResetError. Requests then catches this and raises it's own ConnectionError.

The problem here does not seem to be requests, but instead a misbehaving server.


On a side note, having the username and password in a URL is a very bad idea. I would advise investigating using HTTP Digest Authentication, HTTP Basic Authentication, or implementing something more secure (like a token based authentication scheme).

https://en.xdnf.cn/q/70129.html

Related Q&A

numpy and pandas timedelta error

In Python I have an array of dates generated (or read from a CSV-file) using pandas, and I want to add one year to each date. I can get it working using pandas but not using numpy. What am I doing wron…

Pandas - split large excel file

I have an excel file with about 500,000 rows and I want to split it to several excel file, each with 50,000 rows.I want to do it with pandas so it will be the quickest and easiest.any ideas how to make…

Unable to verify secret hash for client at REFRESH_TOKEN_AUTH

Problem"Unable to verify secret hash for client ..." at REFRESH_TOKEN_AUTH auth flow. {"Error": {"Code": "NotAuthorizedException","Message": "Unab…

save a dependecy graph in python

I am using in python3 the stanford dependency parser to parse a sentence, which returns a dependency graph. import pickle from nltk.parse.stanford import StanfordDependencyParserparser = StanfordDepend…

What are the specific rules for constant folding?

I just realized that CPython seems to treat constant expressions, which represent the same value, differently with respect to constant folding. For example:>>> import dis >>> dis.dis(…

installing opencv for python on mavericks

I am trying to install opencv on a Macbook Pro late 2013 with mavericks. I didnt find any binaries so I am trying to build it. I tried http://www.guidefreitas.com/installing-opencv-2-4-2-on-mac-osx-mou…

Python 3 reading CSV file with line breaks in rows

I have a large CSV file with one column and line breaks in some of its rows. I want to read the content of each cell and write it to a text file but the CSV reader is splitting the cells with line brea…

Python appending dictionary, TypeError: unhashable type?

abc = {} abc[int: anotherint]Then the error came up. TypeError: unhashable type? Why I received this? Ive tried str()

Calling C# code within Python3.6

with absolutely no knowledge of coding in C#, I wish to call a C# function within my python code. I know theres quite a lot of Q&As around the same problem, but for some strange reason, im unable t…

Pycharm 3.4.1 - AppRegistryNotReady: Models arent loaded yet. Django Rest framewrok

Im using DRF and Pycharm 3.4.1 and Django 1.7. When I try to test my serializer class via Pycharm django console, it gives me the following error:Codefrom items_app.serializers import ItemSerializer s …