Example #1
0
def bsend(x, destination, use_buffer=False, vanilla=False,
         tag=default_tag, bypass=False):

    if bypass is True:
        #print "bsend_array() bypass True"
        bsend_array(x, destination, tag)
        return

    import types, string
        
    # Input check.
    errmsg = 'Destination id (%s) must be an integer.' %destination
    assert type(destination) == types.IntType, errmsg
    
    errmsg = 'Tag %d is reserved by pypar - please use another.' %control_tag
    assert tag != control_tag, errmsg

    # Create metadata about object to be sent
    control_info, x = create_control_info(x, vanilla, return_object=True)
    protocol = control_info[0]

    # Possibly transmit control data
    if use_buffer is False:
       send_control_info(control_info, destination)   
      
    # Transmit payload data    
    if protocol == 'array':
        bsend_array(x, destination, tag)    
        #print "bsend_array() bypass False"
    elif protocol in ['string', 'vanilla']:
        bsend_string(x, destination, tag)          
        #print "bsend_string()"
    else:
        raise 'Unknown protocol: %s' %protocol
Example #2
0
def bsend(x,
          destination,
          use_buffer=False,
          vanilla=False,
          tag=default_tag,
          bypass=False):

    if bypass is True:
        bsend_array(x, destination, tag)
        return

    # Input check.
    errmsg = 'Destination id (%s) must be an integer.' % destination
    assert type(destination) == types.IntType, errmsg

    errmsg = 'Tag %d is reserved by pypar - please use another.' % control_tag
    assert tag != control_tag, errmsg

    # Create metadata about object to be sent
    control_info, x = create_control_info(x, vanilla, return_object=True)
    protocol = control_info[0]

    # Possibly transmit control data
    if use_buffer is False:
        send_control_info(control_info, destination)

    # Transmit payload data
    if protocol == 'array':
        bsend_array(x, destination, tag)
    elif protocol in ['string', 'vanilla']:
        bsend_string(x, destination, tag)
    else:
        raise 'Unknown protocol: %s' % protocol