def _should_allocate_port(pid):
    """Determine if we should allocate a port for use by the given process id."""
    if pid <= 0:
        log.info('Not allocating a port to invalid pid')
        return False
    if pid == 1:
        # The client probably meant to send us its parent pid but
        # had been reparented to init.
        log.info('Not allocating a port to init.')
        return False
    try:
        os.kill(pid, 0)
    except ProcessLookupError:
        log.info('Not allocating a port to a non-existent process')
        return False
    return True
def _should_allocate_port ( pid ) : if pid <= 0 : log . info ( 'Not allocating a port to invalid pid' ) return False if pid == 1 : log . info ( 'Not allocating a port to init.' ) return False try : os . kill ( pid , 0 ) except ProcessLookupError : log . info ( 'Not allocating a port to a non-existent process' ) return False return True
Determine if we should allocate a port for use by the given process id.