def _send_request(self, conn: HTTPConnection): req_body = { "jsonrpc": "2.0", "method": self.jsonrpc_method, "params": self.jsonrpc_params, "id": repr(self), } conn.request( method=self.method, url=urlunparse(self.url), body=json.dumps(req_body), headers={"Accept": "application/json", "Content-Type": "application/json"}, )
def _send_request(self, conn: HTTPConnection): req_body = { 'jsonrpc': '2.0', 'method': self.jsonrpc_method, 'params': self.jsonrpc_params, 'id': repr(self), } conn.request( method=self.method, url=urlunparse(self.url), body=json.dumps(req_body), headers={ 'Accept': 'application/json', 'Content-Type': 'application/json' }, )
def after_start_check(self): """ Check if defined URL returns expected status to a <method> request. """ try: if self.url.scheme == "http": conn = HTTPConnection(self.host, self.port) elif self.url.scheme == "https": ssl_context = None if not self.verify_tls: ssl_context = ssl._create_unverified_context() conn = HTTPSConnection(self.host, self.port, context=ssl_context) else: raise ValueError( f'Unsupported URL scheme: "{self.url.scheme}"') self._send_request(conn) response = conn.getresponse() status = str(response.status) if not self._validate_response(response): return False if status == self.status or self.status_re.match(status): conn.close() return True except (HTTPException, socket.timeout, socket.error) as ex: log.debug("Executor process not healthy yet", command=self.command, error=ex) time.sleep(0.1) return False return False
def after_start_check(self): """ Check if defined URL returns expected status to a <method> request. """ try: conn = HTTPConnection(self.host, self.port) conn.request(self.method, self.url.path) status = str(conn.getresponse().status) if status == self.status or self.status_re.match(status): conn.close() return True except (HTTPException, socket.timeout, socket.error): return False
def after_start_check(self): """ Check if defined URL returns expected status to a <method> request. """ try: if self.url.scheme == 'http': conn = HTTPConnection(self.host, self.port) elif self.url.scheme == 'https': conn = HTTPSConnection( self.host, self.port, context=ssl._create_unverified_context(), ) else: raise ValueError( f'Unsupported URL scheme: "{self.url.scheme}"') conn.request(self.method, self.url.path) status = str(conn.getresponse().status) if status == self.status or self.status_re.match(status): conn.close() return True except (HTTPException, socket.timeout, socket.error): return False
def after_start_check(self): """ Check if defined URL returns expected status to a <method> request. """ try: if self.url.scheme == 'http': conn = HTTPConnection(self.host, self.port) elif self.url.scheme == 'https': conn = HTTPSConnection( self.host, self.port, context=ssl._create_unverified_context(), ) else: raise ValueError(f'Unsupported URL scheme: "{self.url.scheme}"') conn.request(self.method, self.url.path) status = str(conn.getresponse().status) if status == self.status or self.status_re.match(status): conn.close() return True except (HTTPException, socket.timeout, socket.error): return False
def _send_request(self, conn: HTTPConnection): conn.request(self.method, self.url.path)