在Python多线程应用程序中将变量设置为无

在Python多线程应用程序中将变量设置为无,python,multithreading,Python,Multithreading,我有一个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.

我有一个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\u fetch\u timeline
在父线程中设置

是启动线程的代码

此应用程序运行了一段时间,然后突然以这种方式失败

在当前失败的同一个方法中,我最初得到错误
NoneType对象没有属性debug
,因为我在父线程中创建的记录器实例上调用了
logger.debug(…)
。我用以下代码修复了这个问题,但现在怀疑我是在修复症状,而不是问题:

    try:
        logger
    except NameError:
        logger = None
    finally:
        if logger == None:
            import logging
            logger = logging.getLogger('Twitter Enrichment')

我遗漏的根本问题是什么

您能否显示启动流程的代码?已更新。另外,还有一个更新:它总是在崩溃前保存9个用户的数据。总是9点。