From b6c0fd34cdbc742fab6fdbc86cbedc156b74c03c Mon Sep 17 00:00:00 2001 From: Niklas Just Date: Fri, 22 Nov 2024 10:51:00 +0100 Subject: [PATCH] change events from reference to copy Signed-off-by: Niklas Just --- openleadr/service/event_service.py | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/openleadr/service/event_service.py b/openleadr/service/event_service.py index 23eae14..0c09c24 100644 --- a/openleadr/service/event_service.py +++ b/openleadr/service/event_service.py @@ -14,10 +14,12 @@ # See the License for the specific language governing permissions and # limitations under the License. -from . import service, handler, VTNService import asyncio -from openleadr import utils, errors, enums import logging + +from openleadr import utils, errors, enums +from . import service, handler, VTNService + logger = logging.getLogger('openleadr') @@ -28,7 +30,7 @@ def __init__(self, vtn_id, polling_method='internal'): super().__init__(vtn_id) self.polling_method = polling_method self.events = {} - self.completed_event_ids = {} # Holds the ids of completed events + self.completed_event_ids = {} # Holds the ids of completed events self.event_callbacks = {} self.event_opt_types = {} self.event_delivery_callbacks = {} @@ -41,7 +43,7 @@ async def request_event(self, payload): ven_id = payload['ven_id'] if self.polling_method == 'internal': if ven_id in self.events and self.events[ven_id]: - events = utils.order_events(self.events[ven_id]) + events = utils.order_events(self.events[ven_id].copy()) for event in events: event_status = utils.getmember(event, 'event_descriptor.event_status') # Pop the event from the events so that this is the last time it is communicated