requests / SSL blocks forever?
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
--
https://mail.python.org/mailman/listinfo/python-list
Re: requests / SSL blocks forever?
On 13/01/18 11:34, Nagy László Zsolt wrote: > 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 Unfortunately, this traceback doesn't contain any of your own code, so we can't really tell what you're trying to do, or whether this call *should* be terminating. > [snip] > > File: "C:\Python36-32\lib\site-packages\OpenSSL\SSL.py", line 1624, in > recv_into > result = _lib.SSL_read(self._ssl, buf, nbytes) so - this is calling a C library. At that point, if the C function doesn't return, there's not really anything Python can do. My point is: if the server is simply not sending a response (because it's waiting for you to send more data, or whatever) but *is* keeping the TCP connection alive - this could make sense. Are you setting a timeout? -- Thomas > > 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 > > > -- https://mail.python.org/mailman/listinfo/python-list
pip --user by default
Hi, I recently discovered the wonders of pip.conf: if I create a file ~/.config/pip/pip.conf* with: [install] user = true then pip will install to the --user site-packages by default, rather than trying to install packages into system directories. The trouble is that this fails when you also use virtualenvs. In a virtualenv, --user doesn't work, so pip fails when trying to install anything in a virtualenv as long as the user pip.conf contains those lines. Short of adding a pip.conf to every single virtualenv, is there any way to work around this, and configure pip to install packages - into the user directories if possible - into the environment when in an environment by default? Thanks, Thomas * the path obviously depends on the OS: https://pip.pypa.io/en/stable/user_guide/#config-file -- https://mail.python.org/mailman/listinfo/python-list
Re: requests / SSL blocks forever?
On 2018-01-13, Nagy László Zsolt wrote: > 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. (a) are you setting daemon=True on the thread? (b) are you setting a timeout on the requests call? -- https://mail.python.org/mailman/listinfo/python-list
anyway you can connect your reddit to your crypto account to send people coins?
wondering if its possible to have a bot that is able to send coins to a person if you choose to -- https://mail.python.org/mailman/listinfo/python-list
Re: Pandas printing in jupyter
Rustom Mody writes:
> Specifically and for starters, I want a numpy array — lets say 2D to
> start with — to be displayed(displayable) as elegantly as sympy does
> to (its) matrices
import numpy as np
from IPython.display import Latex
def prmat(mat):
return (r'\begin{bmatrix}' +
r'\\'.join('&'.join('%f'%x for x in row) for row in mat) +
r'\end{bmatrix}'
a = np.arange(12).reshape((3, 4))+1
display(Latex(prmat(a)))
you could add optional arguments to modify the type of brackets and the
formatting string
--
https://mail.python.org/mailman/listinfo/python-list
Re: Pandas printing in jupyter
[email protected] writes: > def prmat(mat): > return (r'\begin{bmatrix}' + > r'\\'.join('&'.join('%f'%x for x in row) for row in mat) + > r'\end{bmatrix}' add a closing parenthesis here ^ -- https://mail.python.org/mailman/listinfo/python-list
