Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
jiklas-nust opened this issue Nov 22, 2024 · 2 comments
Open

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

jiklas-nust opened this issue Nov 22, 2024 · 2 comments

Comments

@jiklas-nust
Copy link

jiklas-nust commented Nov 22, 2024

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.

@axmsoftware
Copy link
Contributor

axmsoftware commented Nov 22, 2024 via email

@jiklas-nust
Copy link
Author

Hi Arila,

thanks for replying. Could you get me through the steps of submitting a pull request? Do I need to fork the repo in order to?
I tried creating a new branch but it won't let me push this branch to the remote.
It's my first contribution to a public repo so I'm a little bit lost here.

Thanks, Jiklas

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants