Skip to content

Conversation

@loerum
Copy link
Contributor

@loerum loerum commented Jul 18, 2019

Trying to receive messages from a not registered service will create an infinite loop, the following code will print None forever:

from posttroll.subscriber import Subscribe
with Subscribe("invalid_service", "counter",) as sub:
for msg in sub.recv():
    print(msg)

It's fixed by raising an exception in Subscriber.recv if no socket to poll.

I'm some what surprised that we first see this "feature" now ... so please check if I have missed something.

@coveralls
Copy link

Coverage Status

Coverage decreased (-0.09%) to 79.62% when pulling d34f427 on fix-infinite-loop into 516725e on master.

@loerum
Copy link
Contributor Author

loerum commented Jul 30, 2019

By the way, the above infinite loop, would not have happen if an addr_listener was specified:

from posttroll.subscriber import Subscribe
with Subscribe("invalid_service", "counter", addr_listener=True) as sub:
for msg in sub.recv():
    print(msg)

In this case, there is always something to poll. Maybe if a name-server is been used, addr_listener should have the default value True ?

@mraspaud
Copy link
Member

I'm not in the office, please remind me to look at this next week

Copy link
Member

@mraspaud mraspaud left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for this, could you add a small unit test for this @loerum ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants