Ejemplo n.º 1
0
def set_up_spread_peer():
    '''
    Set up Spread utility for Spread peer
    @return Tuple of (Spread mailbox, Spread message object for sending, 
        Spread message object for receiving, group list of the mailbox)
    '''

    # Register the signal timeout handler
    signal.signal(signal.SIGALRM, timeout_handler)

    group_list = spread.GroupList()
    group_list.add(params.SPREAD_GROUP_NAME)

    try:
        mbox = spread.Mailbox(params.SPREAD_DAEMON_PORT, "vyan1_mbox", False,
                              0)
    except spread.Error as error:
        error._print()
        raise error
    mbox.join(params.SPREAD_GROUP_NAME)
    mbox.add_group(params.SPREAD_GROUP_NAME)

    send_MSG = spread.Message()
    rcv_MSG = spread.Message()
    service = spread.Message.Reliable | spread.Message.SelfDiscard
    send_MSG.set_service(service)

    return (mbox, send_MSG, rcv_MSG, group_list)
Ejemplo n.º 2
0
def set_up_start_spread():
    '''
    Set up Spread utility for start_spread program
    @return (Spread mailbox, Spread message object for sending)
    '''

    try:
        mbox = spread.Mailbox(params.SPREAD_DAEMON_PORT, "start_spread", False,
                              0)
    except spread.Error as error:
        error._print()
        raise error
    mbox.add_group(params.SPREAD_GROUP_NAME)

    send_MSG = spread.Message()
    service = spread.Message.Reliable | spread.Message.SelfDiscard
    send_MSG.set_service(service)

    return (mbox, send_MSG)
Ejemplo n.º 3
0
'''
Signaling program to start multicast process for all MNIST peers

Author: Yuan Jing Vincent Yan ([email protected])
'''
import spread
import params

if __name__ == '__main__':
    try:
        mbox = spread.Mailbox(params.SPREAD_DAEMON_PORT, "start_spread", False,
                              0)
    except spread.Error as error:
        error._print()
        raise error

    send_msg = spread.Message()
    service = spread.Message.Reliable | spread.Message.SelfDiscard
    send_msg.set_service(service)

    mbox.add_group(params.SPREAD_GROUP_NAME)
    send_msg.write(params.START_SPREAD_SIGNAL)
    mbox.send(send_msg)
    print("start_mcast: Let the show begin!")
Ejemplo n.º 4
0
import sys
import spread

group_name = "JHU_VDL"
group_list = spread.GroupList()
group_list.add(group_name)

try:
    mbox = spread.Mailbox("4803", "", False, 0)
except spread.Error as error:
    error._print()
    raise error
message = spread.Message()
rcv_msg = spread.Message()

data = "foobar"
service = spread.Message.Reliable | spread.Message.SelfDiscard
#message.set_service(service)

mbox.clear_groups()
mbox.clear_message_parts()
mbox.join(group_name)  #

mbox.add_group(group_name)
message.write(data)
mbox.send(message)

while mbox.poll() == 0:
    pass
print 'poll ', mbox.poll()
#mbox.send(message, group_list)