mirror of
https://github.com/openvswitch/ovs
synced 2025-08-22 09:58:01 +00:00
ovs-dpctl-top: Fix RuntimeError with resizing flow dict during iteration.
Python does not allow modifying a dictionary or list while iterating over the elements. The common idom to work around this is to create a copy of the keys or elements and then use that information to delete the corresponding entries from the original dictionary. This patch changes the iteration to use an intermediate copy and then modify the original dictionary. This avoids the associated RuntimeError. Reported-by: Eelco Chaudron <echaudro@redhat.com> Reported-at: https://mail.openvswitch.org/pipermail/ovs-dev/2024-August/417000.html Acked-by: Eelco Chaudron <echaudro@redhat.com> Fixes: 14b4c575c284 ("utilities: a top like tool for ovs-dpctl dump-flows.") Signed-off-by: Aaron Conole <aconole@redhat.com>
This commit is contained in:
parent
0051785f00
commit
604e54fc3c
@ -1007,7 +1007,7 @@ class FlowDB:
|
||||
def decay(self, decayTimeInSeconds):
|
||||
""" Decay content. """
|
||||
now = datetime.datetime.now()
|
||||
for (key, value) in self._flows.items():
|
||||
for (key, value) in list(self._flows.items()):
|
||||
(stats_dict, updateTime) = value
|
||||
delta = now - updateTime
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user