2

oauth 库(从Justin.tv Python 库页面链接)在随机时间无限期地锁定我的 Python 进程。这是随机发生的,但经常发生在我的一台服务器上。我很肯定这不是由于我的代码中的任何内容,所以我粘贴了与 Justin.tv python 库和 oauth 相关的堆栈转储部分:

  文件“/home/honstreams/honstreams/website/JtvClient.py”,第 51 行,在 get
    return self._send_request(request, token)
  _send_request 中的文件“/home/honstreams/honstreams/website/JtvClient.py”,第 90 行
    返回 conn.getresponse()
  文件“/usr/lib/python2.6/httplib.py”,第 986 行,在 getresponse 中
    response.begin()
  文件“/usr/lib/python2.6/httplib.py”,第 391 行,开始
    版本、状态、原因 = self._read_status()
  _read_status 中的文件“/usr/lib/python2.6/httplib.py”,第 349 行
    line = self.fp.readline()
  文件“/usr/lib/python2.6/socket.py”,第 397 行,在 readline
    数据 = 接收 (1)
键盘中断

底线是它在KeyboardInterrupt. 我将永远留在这条线上,或者至少在我让它运行的几天内。

socket.py即使设置了超时(有时确实超时),我对任何可以锁定的方式以及可以防止它的任何方式都很感兴趣。


这是更多信息

root@foo:~# python --version
Python 2.6.5
root@foo:~# uname -a
Linux foo.bar.no 2.6.32-31-generic-pae #61-Ubuntu SMP Fri Apr 8 20:00:13 UTC 2011 i686 GNU/Linux
4

1 回答 1

2

Justin.tv Python 客户端库中的这些行是相关的:

def _send_request(self, request, token=None):
    request.sign_request(OAuthSignatureMethod_HMAC_SHA1(), self.consumer, token)
    conn = self._get_conn() # connection was requested here
    if request.http_method == 'POST':
        conn.request('POST', request.http_url, body=request.to_postdata())
    else:
        conn.request('GET', request.http_url, headers=request.to_header())
    return conn.getresponse()  # Error occurs here

def _get_conn(self):
    return httplib.HTTPConnection("%s:%d" % (self.host, self.port)) # no timeout!

请注意,httplib.HTTPConnection没有通过任何超时。更改该代码以超时,并确保定义发生超时时会发生什么。

于 2011-10-14T21:40:41.493 回答