requests / SSL blocks forever?
Nagy László Zsolt
gandalf at shopzeus.com
Sat Jan 13 05:34:18 EST 2018
Hi!
I have a multi threaded Windows service written in Python. It is running
on 3.6.2. Sometimes I cannot stop the service, because on of the
threads won't exit. I have narrowed down the problem to request and
_lib.SSL_read. I have used a modified version of this gem:
http://code.activestate.com/recipes/577334-how-to-debug-deadlocked-multi-threaded-programs/
So even thould I cannot stop the service (only kill it from task
manager), I can tell that this is the rebellious thread:
File: "C:\Python36-32\lib\site-packages\requests\api.py", line 112, in post
return request('post', url, data=data, json=json, **kwargs)
File: "C:\Python36-32\lib\site-packages\requests\api.py", line 58, in
request
return session.request(method=method, url=url, **kwargs)
File: "C:\Python36-32\lib\site-packages\requests\sessions.py", line 508,
in request
resp = self.send(prep, **send_kwargs)
File: "C:\Python36-32\lib\site-packages\requests\sessions.py", line 658,
in send
r.content
File: "C:\Python36-32\lib\site-packages\requests\models.py", line 823,
in content
self._content = bytes().join(self.iter_content(CONTENT_CHUNK_SIZE)) or
bytes()
File: "C:\Python36-32\lib\site-packages\requests\models.py", line 745,
in generate
for chunk in self.raw.stream(chunk_size, decode_content=True):
File: "C:\Python36-32\lib\site-packages\urllib3\response.py", line 436,
in stream
data = self.read(amt=amt, decode_content=decode_content)
File: "C:\Python36-32\lib\site-packages\urllib3\response.py", line 384,
in read
data = self._fp.read(amt)
File: "C:\Python36-32\lib\http\client.py", line 449, in read
n = self.readinto(b)
File: "C:\Python36-32\lib\http\client.py", line 493, in readinto
n = self.fp.readinto(b)
File: "C:\Python36-32\lib\socket.py", line 586, in readinto
return self._sock.recv_into(b)
File: "C:\Python36-32\lib\site-packages\urllib3\contrib\pyopenssl.py",
line 280, in recv_into
return self.connection.recv_into(*args, **kwargs)
File: "C:\Python36-32\lib\site-packages\OpenSSL\SSL.py", line 1624, in
recv_into
result = _lib.SSL_read(self._ssl, buf, nbytes)
It is possible that there are network outages on this machine, but I
don't think that this should result in an infinite block.
The bigest problem is that the only way to restart the service is to
login remotely, start the task manager and terminate the
pythonservice.exe process.
Do any of you have a clue why is this happening? How to fix this?
Thanks,
Laszlo
More information about the Python-list
mailing list