def __getitem__(self, key): url = self._url.format(method="GET", key=key) string = request.urlopen(url, timeout=.5).read().decode("utf-8") value = string.split("\t")[-1][:-1] if not value: raise UndefinedExtStateError(key) value = json.loads(value) return value
def _get_request(self, connection, address): try: request = connection.recv() request = json.loads(request.decode()) except (ConnectionAbortedError, ConnectionResetError): # Client has disconnected # Pretend client has nicely requested to disconnect input = {"args": (address, ), "kwargs": {}} request = {"function": self.disconnect, "input": input} return request
def _get_result(self): s = self.recv(timeout=None).decode() return json.loads(s)