小编use*_*472的帖子

在Python 3中从服务器返回回复时引发BadStatusLine异常

我正在尝试将脚本移植到python 3,它提交了以下XML提要:

https://developers.google.com/search-appliance/documentation/files/pushfeed_client.py.txt

运行2to3.py并进行一些小的调整以删除任何语法错误后,脚本将失败并显示:

(py33dev) d:\dev\workspace>python pushfeed_client.py --datasource="TEST1" --feedtype="full" --url="http://gsa:19900/xmlfeed" --xmlfilename="test.xml"
Traceback (most recent call last):
  File "pushfeed_client.py", line 108, in <module>
    main(sys.argv)
  File "pushfeed_client.py", line 56, in main
    result = urllib.request.urlopen(request_url)
  File "C:\Python33\Lib\urllib\request.py", line 156, in urlopen
    return opener.open(url, data, timeout)
  File "C:\Python33\Lib\urllib\request.py", line 469, in open
    response = self._open(req, data)
  File "C:\Python33\Lib\urllib\request.py", line 487, in _open
    '_open', req)
  File "C:\Python33\Lib\urllib\request.py", line 447, in _call_chain
    result = func(*args)
  File "C:\Python33\Lib\urllib\request.py", line 1268, in http_open
    return self.do_open(http.client.HTTPConnection, req)
  File "C:\Python33\Lib\urllib\request.py", …
Run Code Online (Sandbox Code Playgroud)

python google-search-appliance python-3.x

6
推荐指数
1
解决办法
6527
查看次数

线程上的Start方法因TypeError而失败

我收到以下错误

错误:

tt.start()

TypeError: 'int' object is not callable
Run Code Online (Sandbox Code Playgroud)

我将子线程继承.线程只是跟踪时间,当经过的时间与传入的任意值匹配时,它会将匹配键的值从输入字典添加到队列中.另一个线程将定期检查队列,查找工作和进程,因为它找到任何.

这是抛出错误的代码:

class TimerQueue(threading.Thread):

    def __init__(self, qyoo, kwargs):
        threading.Thread.__init__(self)
        self.queue = qyoo
        self.work = kwargs
        self.start = ceiling(time.time())
        self.times = kwargs.keys()


    def run(self):
        while True:
            for t in self.times:
                if ceiling(time.time()) - self.start == t:
                    logger.debug("adding {} to the queue".format(self.work[t]))
                    self.queue.put(self.work[t])
            time.sleep(1)

if __name__ == "__main__":
    input_queue = queue.Queue()
    tt = TimerQueue(input_queue, time_url_dict)
    tt.start()
Run Code Online (Sandbox Code Playgroud)

为什么我在调用start时收到错误?这是在运行Windows 7的Python 3.3.3中.

python windows multithreading python-3.x python-3.3

4
推荐指数
1
解决办法
2422
查看次数