pyre icon indicating copy to clipboard operation
pyre copied to clipboard

No way to detect when a Pyre's ZBeacon has exited

Open SillyFreak opened this issue 8 years ago • 1 comments

To illustrate, run this:

import logging
from pyre import Pyre

logger = logging.getLogger('pyre')
logger.setLevel(logging.DEBUG)
logger.addHandler(logging.StreamHandler())

pyre = Pyre()
pyre.start()

As long as there's a network connection during startup, you will get output like this:

...
Set up a broadcast beacon to w.x.y.z:5670

When you disable your network connection, you will get the following output:

Network seems gone, exiting zbeacon

(in addition, if the network was not available during startup, there's an exception in prepare_udp)

The corresponding actor exits and sends shim_pipe.signal() (i.e. a single part message), but PyreNode ignores this. In particular, this happens here:

def recv_beacon(self):
    # Get IP address and beacon of peer
    try:
        ipaddress, frame = self.beacon_socket.recv_multipart()
    except ValueError:
        return 

I don't see a way to work around this while still using the Pyre class, and I'm not sure about the proper fix. Is a node without a beacon useful, or is that a reason for shutting the Node down?

SillyFreak avatar Aug 05 '16 16:08 SillyFreak

We should mimic Zyre's behaviour. I'm not sure what that is currently.

In general we should raise an exception so the user can decide.

Zyre uses zsys's udp methods: https://github.com/zeromq/czmq/blob/master/src/zsys.c#L889 They will return -1 if a send fails. Zbeacon does nothing with -1 so it will continue if the network is gone...

https://github.com/zeromq/czmq/blob/master/src/zbeacon.c#L300

However I'm not sure if the beacon will continue if the network is back... Has anybody tested such behaviour?

sphaero avatar Aug 08 '16 14:08 sphaero