我在Python中有一个小型多线程应用程序,它最近给了我一些错误:
Exception in thread Thread-2:
Traceback (most recent call last):
File "/usr/local/Cellar/python/2.7.12_2/Frameworks/Python.framework/Versions/2.7/lib/python2.7/threading.py", line 801, in __bootstrap_inner
self.run()
File "enrichment/twitter_enrichment.py", line 368, in run
self.get_user()
File "enrichment/twitter_enrichment.py", line 332, in get_user
self.queueWorkItem.do_work(self.twitterClient)
File "enrichment/twitter_enrichment.py", line 300, in do_work
return work(twitterClient)
File "enrichment/twitter_enrichment.py", line 284, in fetch_timeline
self.user.newest_tweet_id_str
File "enrichment/twitter_enrichment.py", line 94, in twitter_drain_timeline
timeLine = twitter_fetch_timeline(client, user_id, since_id=since_id, max_id=max_id)
TypeError: 'NoneType' object is not callable
方法twitter_fetch_timeline
在父线程中设置。
Here是启动我的线程的代码。
此应用程序运行一段时间,然后突然以这种方式失败。
在当前失败的同一方法中,我最初收到错误NoneType object does not have attribute debug
,因为我在父线程中创建的记录器实例上调用了logger.debug(...)
。我用以下代码解决了这个问题,但现在怀疑我正在修复症状而不是问题:
try:
logger
except NameError:
logger = None
finally:
if logger == None:
import logging
logger = logging.getLogger('Twitter Enrichment')
我错过了什么根本问题?