錯誤:unbound method read() must be called with RawConfigParser instance as first argument (got str instance instead)
解答:因爲read不是靜態方法,所以必須實例化才能使用
錯誤:ValueError: dictionary update sequence element #0 has length 1; 2 is required
解答:字典和字符串的轉換,不單單是指str() dict()之間的轉換,即使這樣做,也會繼續報這個錯誤
字符串和字典的轉換要用eval()
peewee 使用報錯 peewee.InterfaceError: (0, '')
經查原因是需要添加數據庫連接池,長連接導致沒有了連接
peewee 使用報錯 Exceed max connections 連接池滿了:
背景: 使用playhouse鏈接池,加斷開重連應用於多線程
使用database.connection_context()在使用萬鏈接自動斷開,依舊會出現這樣的錯誤
ThreadPoolExexutor 的使用
如果我們要使用的方法是要傳遞一個需要迭代的參數,可以使用map
如果有固定的參數和迭代的參數,可以使用submit
參考樣例,親測可以
with ThreadPoolExecutor(max_workers=3) as executor:
future_tasks = [executor.submit(函數,迭代參數,非迭代參數)for 迭代參數 in 迭代參數數組]
for future in as_completed(future_tasks): # 迭代生成器
try:
future.result()
except Exception as e:
print('%s' % e)
# 獲取campaign的成效數據
with ThreadPoolExecutor(max_workers=3) as executor:
executor.map(函數,迭代參數數組)