Skip to content

Commit caf75c3

Browse files
committed
fix mistake in removing within the loop
1 parent 24ac9ba commit caf75c3

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

intelmq/bin/intelmqctl.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -578,10 +578,11 @@ def botnet_stop(self, group=None):
578578
# give the bots some time to terminate
579579
time.sleep(sleep_time)
580580
# update the botnet_status
581-
for bot_id in stopped_but_still_running_bots:
582-
botnet_status[bot_id] = self.bot_status(bot_id)[1]
583-
if botnet_status[bot_id] in ['stopped', 'disabled']:
584-
stopped_but_still_running_bots.remove(bot_id)
581+
# only keep bots in the list which are not stopped already
582+
stopped_but_still_running_bots = list(filter(
583+
lambda bot_id: self.bot_status(bot_id)[1] not in ['stopped', 'disabled'],
584+
stopped_but_still_running_bots
585+
))
585586

586587
# check if all bots are stopped -> no need to wait further
587588
if not stopped_but_still_running_bots:

0 commit comments

Comments
 (0)