1. Benjamin Smith
  2. python-stomp
Issue #9 open

Potential infinite loop on sock.recv(1) in _getline.

Eric Van Dewoestine
created an issue

We've recently run into an issue under load when a process can get stuck in a state where it loops indefinitely while consuming all cpu resources. We tracked down the issue to a sock.recv(1) while stompy is attempting to receive a response from the messaging server (activemq in our case). It appears that the socket enters a state where recv continues to return 0 bytes but stompy continues to spin on the socket with no exit condition.

Solving this for blocking connections should be simple since //partial// can be set to a single space and then the while condition can additionally exit if //partial// is empty. For non-blocking connections the fix is probably a little trickier, requiring using //select// periodically to determine if the socket is still usable.

Here is the relevant stack trace:

{{{ File "/usr/local/lib/python2.6/dist-packages/stompy/simple.py", line 96, in connect self.stomp.connect(username=username, password=password, clientid=clientid) File "/usr/local/lib/python2.6/dist-packages/stompy/stomp.py", line 48, in connect self.frame.connect(self.sock, username=username, password=password, clientid=clientid) File "/usr/local/lib/python2.6/dist-packages/stompy/frame.py", line 95, in connect next_frame = self.get_reply() File "/usr/local/lib/python2.6/dist-packages/stompy/frame.py", line 180, in get_reply frame = self.parse_frame(nb=nb) File "/usr/local/lib/python2.6/dist-packages/stompy/frame.py", line 200, in parse_frame line = self._getline(nb=nb) File "/usr/local/lib/python2.6/dist-packages/stompy/frame.py", line 268, in _getline partial = self.sock.recv(1) }}}

Comments (3)

  1. Log in to comment