def get_host(self, task_host): if not self.host: sub, top = utils.split_domain(task_host) self.host = utils.to_str(sub) + "." + utils.to_str( self.ssl_sock.host) return self.host
def __call__(self, environ, start_response): domain, port = host_utils.split_hostname(environ['HTTP_HOST']) project = registered_domain(self.settings, domain) if project and project.count(host_utils.SEP_DOMAIN) == 1: username, project_name = host_utils.split_domain(project) else: if not domain.endswith(self.settings.hosting.domain): return handle_exception('404 Not Found', start_response) name = host_utils.split_subdomain(self.settings.hosting.domain, domain) if not name: username = '******' project_name = 'hosting' elif name.count(host_utils.SEP_DOMAIN) == 1: project_name, username = host_utils.split_domain(name) else: return handle_exception('403 Forbidden', start_response) app_dir = os.path.join( os.path.abspath(self.settings.hosting.project_dir), '%s/%s' % (username, project_name)) app_settings = os.path.join(app_dir, 'settings.py') if not os.path.exists(app_settings): return handle_exception('404 Not Found', start_response) handler_conn, proj_conn = Pipe() proc = Process(target=handle_project, args=(self.settings, username, project_name, environ, proj_conn)) proc.start() start_response(*handler_conn.recv()) resp = handler_conn.recv() proc.join() return resp
def __init__(self, host, ssl_timeout_cb): self.thread_num_lock = threading.Lock() sub, top = utils.split_domain(host) self.sub = sub self.class_name = "Https_connection_manager" self.connect_timeout = 4 self.thread_num = 0 # after new created ssl_sock timeout(50 seconds) # call the callback. # This callback will put ssl to worker self.ssl_timeout_cb = ssl_timeout_cb self.connecting_more_thread = None self.load_config() p = threading.Thread(target=self.keep_alive_thread) p.daemon = True p.start() self.create_more_connection()
def get_host(self, task_host): if not self.host: sub, top = utils.split_domain(task_host) self.host = sub + "." + self.ssl_sock.host return self.host
def test_split_domain(self): self.assertEqual(utils.split_domain('myproject.myname.example.com'), ['myproject', 'myname', 'example', 'com'])