2016-10-30 1216 views
0

我已經構建了一個python腳本,用於管理我的池中一堆不同的東西。我一直在增加更多的功能,並在我的Raspberry Pi上運行一些超時功能。今天,我開始收到此錯誤:Python - 線程線程1中的異常(在__bootstrap_inner中)

Exception in thread Thread-1: 
Traceback (most recent call last): 
    File "/usr/lib/python2.7/threading.py", line 810, in __bootstrap_inner 
self.run() 
    File "/usr/lib/python2.7/threading.py", line 1082, in run 
self.function(*self.args, **self.kwargs) 
TypeError: 'str' object is not callable 

於是我開始的最後部分(類型錯誤讀了起來:「STR」對象不是可調用和揣摩我一定是把它作爲一個變量,它與內置干擾所以我尋找每一個實例,如果我的代碼中str可以找到(1300行),這就是我找到的所有東西,所以現在我難以理解實際可能導致問題的原因(縮寫爲顯示其中str是:

1) logger.info("Notify socket = {0}".format(str(s_adr))) 
2) ph_value = str(line) 
3)"/input/post.json?&node=" + str(pooldb.ph_node) 
4) orp_value = str(line2) 
5)"/input/post.json?&node=" + str(pooldb.orp_node) 
6) current_military_time = int(datetime.datetime.now().strftime('%H%M')) 

就是它,在1300+行代碼那些「STR」我能找到和他們沒有唯一的實例變量,所以我我很困惑是什麼導致了錯誤。

任何想法將不勝感激。

感謝

回答

1

它可能沒有任何與str()內置。該消息告訴你self.function類型str - 而且字符串實際上是不可調用的。像這樣:

>>> 'ab'(3) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
TypeError: 'str' object is not callable 
>>> 23(3) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
TypeError: 'int' object is not callable 
>>> [7](3) 
Traceback (most recent call last): 
    File "<stdin>", line 1, in <module> 
TypeError: 'list' object is not callable 

你應該看看你是如何創建線程。例如,

>>> import threading 
>>> t = threading.Thread(target="abc") 
>>> t.start() 
Exception in thread Thread-1: 
Traceback (most recent call last): 
    File "C:\Python27\lib\threading.py", line 801, in __bootstrap_inner 
    self.run() 
    File "C:\Python27\lib\threading.py", line 754, in run 
    self.__target(*self.__args, **self.__kwargs) 
TypeError: 'str' object is not callable 
+0

OK,這裏是我打電話線程方式: '進口threading' 'threading.Timer(pooldb.checktime,pool_level)。開始()'這裏 – Richard

+0

沒有人是心靈感應; - )也就是說,沒有人能猜到'pooldb.checktime'和'pool_level'是什麼。如果。例如'pool_level'綁定到一個字符串,那麼你看到的錯誤正是你應該看到的。 http://stackoverflow.com/help/mcve –

+0

我的歉意,我不確定你需要看到什麼幫助。 pool_level是一個完整的函數。這裏顯示在1255行:[link](https://github.com/rjsears/Pool_Fill_Control/blob/master/pool_fill_control.py)和pooldb.checktime在這裏是94行:[link](https:// github.com/rjsears/Pool_Fill_Control/blob/master/pooldb.py) – Richard