Skip to content

event_service.py request_event not working for only one event #175

@jiklas-nust

Description

@jiklas-nust

Hi,

I was setting up a VTN with the 1-minute-Server example from the docs and ran into a problem. As I am running my client in typescript I got a TypeError saying, that my oadrEvent that I got back from polling was not iterable.
The response message to the poll request from the vtn looks like this:

Responding to oadrPoll with a oadrDistributeEvent message:

{
  'events': [],
  'vtn_id': 'myvtn',
  'ven_id': 'ven_id_123',
  'response': {
    'request_id': None,
    'response_code': 200,
    'response_description': 'OK'
  },
  'request_id': '8a23b069-bf08-4769-b9fd-e9b3cfbb94d9'
}

The array which would normally hold the events is empty IF we only have one event in queue.

I cannot really explain why python does this, but when I debugged the request_event function I saw, that

self.events[ven_id].pop(self.events[ven_id].index(event)) (line 55 in event_service.py)

pops the event not only from self.events but also from the referenced variable events, that is later used to fill the response array. And since the function later only checks if events is None, this results in giving back an empty array as a response.

I fixed this by adjusting line 46 where the reference is created and used the copy function to create a copy of self.events rather than a reference to it.

events = utils.order_events(self.events[ven_id].copy())

Is this a real bug or am I missing something? I'm not too familiar with python. I'd love to hear back from you with some advice.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions