示例#1
0
文件: server.py 项目: hansl/habitat
 def _check_ports(self):
     if not 'port' in self:
         self['port'] = self.random_port(self['nb_ports'])
     else:
         port = self['port']
         if not isinstance(port, list):
             port = [port]
         in_use = [str(p) for p in port if util.is_port_in_use(p)]
         if in_use:
             raise Exception(  'Some ports were already in use: %s.'
                             % ', '.join(in_use))
示例#2
0
文件: server.py 项目: hansl/habitat
 def find_nearest_port(port):
     while util.is_port_in_use(port):
         port += 1
     return port