[英]IndexError: list index out of range right after printing len(list) > 0
I literally have these two lines of code in sequence: 我从字面上看依次有这两行代码:
print(len(counter.ondas))
onda = counter.ondas[-1]
I got 13
printed for the first line and it crashed giving me tracebook to the onda = counter.ondas[-1]
line saying IndexError: list index out of range right after printing len(list)
. 我在第一行打印了
13
条,它崩溃了,这使我向trace onda = counter.ondas[-1]
onda onda = counter.ondas[-1]
行的轨迹簿说IndexError: list index out of range right after printing len(list)
。
It works thousands of times before crashing. 在崩溃之前,它可以工作数千次。 I have no clue on how to approach this problem.
我不知道如何解决这个问题。
Output for print(counter.ondas)
: 输出为
print(counter.ondas)
:
[Onda([<workers.mov.Mov object at 0x244EA050>], [Candle(4, 'GBP_JPY', Timestamp('2017-06-12 16:59:00'), 138.884, 138.897, 138.674, 138.76, 10957.0, True)]), Onda([<workers.mov.Mov object at 0x245073D0>], [Candle(4, 'GBP_JPY', Timestamp('2017-06-12 16:59:00'), 138.884, 138.897, 138.674, 138.76, 10957.0, True)...]
Output for print(type(counter.ondas))
: 输出为
print(type(counter.ondas))
:
<class 'list'>
Output for print(isinstance(counter.ondas, list))
: 输出为
print(isinstance(counter.ondas, list))
:
True
Full Error Traceback 完整错误回溯
Traceback (most recent call last):
File "C:\Users\joaoa\AppData\Local\Programs\Python\Python36-32\lib\multiprocessing\pool.py", line 119, in worker
result = (True, func(*args, **kwds))
File "C:\Users\joaoa\AppData\Local\Programs\Python\Python36-32\lib\multiprocessing\pool.py", line 44, in mapstar
return list(map(*args))
File "C:\Users\joaoa\PycharmProjects\aquitania\general_manager.py", line 88, in load_observer_manager
observer_manager.update_load_run_data()
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\management\observer_manager.py", line 78, in update_load_run_data
self.load_run_data()
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\management\observer_manager.py", line 91, in load_run_data
self.feeder.exec_df(df[self.start_date:])
File "C:\Users\joaoa\PycharmProjects\aquitania\data_source\feeder.py", line 429, in exec_df
self.feed(candle)
File "C:\Users\joaoa\PycharmProjects\aquitania\data_source\feeder.py", line 98, in feed
self.make_candle(ts, candle, criteria_table)
File "C:\Users\joaoa\PycharmProjects\aquitania\data_source\feeder.py", line 126, in make_candle
self.set_values(ts, candle)
File "C:\Users\joaoa\PycharmProjects\aquitania\data_source\feeder.py", line 310, in set_values
ts_obs.feed_complete(self._candles[ts])
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\management\observer_loader.py", line 100, in feed_complete
observer.update_last_candle(candle, store_candle)
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\abstract\observer_abc.py", line 93, in update_last_candle
self.set_observe(self.update_method(candle))
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\ondas\ondas_inside.py", line 393, in update_method
self.update_routine(counter_id=2, candle=candle)
File "C:\Users\joaoa\PycharmProjects\aquitania\observer\ondas\ondas_inside.py", line 412, in update_routine
onda = list(counter.ondas)[-1]
IndexError: list index out of range
"""
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:/Users/joaoa/PycharmProjects/aquitania/general_manager.py", line 145, in <module>
gm.run()
File "C:/Users/joaoa/PycharmProjects/aquitania/general_manager.py", line 113, in run
list_of_observer_managers = self.load_all_observer_managers()
File "C:/Users/joaoa/PycharmProjects/aquitania/general_manager.py", line 60, in load_all_observer_managers
observer = currency_pool.map(self.load_observer_manager, list_of_currencies)
File "C:\Users\joaoa\AppData\Local\Programs\Python\Python36-32\lib\multiprocessing\pool.py", line 266, in map
return self._map_async(func, iterable, mapstar, chunksize).get()
File "C:\Users\joaoa\AppData\Local\Programs\Python\Python36-32\lib\multiprocessing\pool.py", line 644, in get
raise self._value
IndexError: list index out of range
I was able to idenfity the issue. 我能够找出问题所在。 The error was being thrown in a separate process than the one that was being printed and for some reason the error ocurred only after the process that was printing the results was interrupted by another unrelated error.
该错误是在与正在打印的过程不同的单独过程中引发的,并且由于某种原因,该错误仅在正在打印结果的过程被另一个不相关的错误中断后才发生。
Weird behavior, but now I am able to tackle the problem. 行为很奇怪,但是现在我可以解决这个问题。
Debugging in a single process mode helped a lot. 在单个过程模式下进行调试有很大帮助。
Thank you for your help. 谢谢您的帮助。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.