Commit 9cec69a
authored
Fix IndexError: list index out of range in resampler (#1117)
When awaiting the resamplers to finish resampling, we need to make a
copy of the resamplers dict, because new resamplers could be added or
removed while we are awaiting, which would cause the results to be out
of sync.
Here is a traceback of an instance of this bug:
```
2024-11-25 12:45:26,052,52 WARNING [_broadcast.py:416] Broadcast receiver [Broadcast:GrpcStreamBroadcaster-raw-component-data-2006:_Receiver] is full. Oldest message was dropped.
2024-11-25 12:45:26,052,52 ERROR [_resampling.py:195] The resample() function got an unexpected error, restarting...
Traceback (most recent call last):
File "/home/marenz/frequenz/sdk/src/frequenz/sdk/microgrid/_resampling.py", line 179, in _log_resampling_task_error
resampling_task.result()
File "/home/marenz/frequenz/sdk/src/frequenz/sdk/timeseries/_resampling.py", line 509, in resample
{
File "/home/marenz/frequenz/sdk/src/frequenz/sdk/timeseries/_resampling.py", line 514, in <dictcomp>
if isinstance(results[i], (Exception, asyncio.CancelledError))
~~~~~~~^^^
IndexError: list index out of range
```File tree
2 files changed
+25
-16
lines changed- src/frequenz/sdk/timeseries
2 files changed
+25
-16
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
3 | 15 | | |
4 | 16 | | |
5 | | - | |
6 | | - | |
| 17 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
14 | 14 | | |
15 | 15 | | |
16 | 16 | | |
17 | | - | |
18 | 17 | | |
19 | 18 | | |
20 | 19 | | |
| |||
495 | 494 | | |
496 | 495 | | |
497 | 496 | | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
498 | 502 | | |
499 | 503 | | |
500 | 504 | | |
501 | 505 | | |
502 | 506 | | |
503 | 507 | | |
504 | | - | |
505 | | - | |
506 | | - | |
507 | | - | |
508 | | - | |
509 | | - | |
510 | | - | |
511 | | - | |
512 | | - | |
513 | | - | |
514 | | - | |
515 | | - | |
516 | | - | |
| 508 | + | |
| 509 | + | |
| 510 | + | |
| 511 | + | |
| 512 | + | |
| 513 | + | |
| 514 | + | |
517 | 515 | | |
518 | 516 | | |
519 | 517 | | |
| |||
0 commit comments