예제 #1
0
파일: zmq.py 프로젝트: zhouxiaoxiang/zato
    def handle(self):
        input = self.request.input
        if input.bind_port and is_port_taken(input.bind_port):
            self.logger.warn('Cannot bind Zero MQ channel `%s` to TCP port %s (already taken)', input.name, input.bind_port)
        else:
            self.server.worker_store.zmq_channel_create(self.request.input)

# ################################################################################################################################
예제 #2
0
def get_free_tcp_port(start=40000, stop=40500):
    """ Iterates between start and stop, returning first free TCP port. Must not be used except for tests because
    it comes with a race condition - another process may want to bind the port we find before our caller does.
    """
    for port in xrange(start, stop):
        if not is_port_taken(port):
            return port
    else:
        raise Exception('Could not find any free TCP port between {} and {}'.format(start, stop))
예제 #3
0
 def ensure_port_free(self, prefix, port, address):
     if is_port_taken(port):
         raise Exception(
             '{} check failed. Address `{}` already taken.'.format(
                 prefix, address))
예제 #4
0
 def ensure_port_free(self, prefix, port, address):
     if is_port_taken(port):
         raise Exception('{} check failed. Address `{}` already taken.'.format(prefix, address))