From 17fe9bf914a98612cd80bff328d958b259531903 Mon Sep 17 00:00:00 2001 From: vigarbuaa Date: Sat, 22 Jun 2019 10:51:50 +0800 Subject: [PATCH] remove not used rest_client MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 1. "json的内容可以通过设置Content-Type为application/json达成,没必要单独增加一个json字段。" remove not used code 2. 在alpaca撤单调试过程中,发生返回值200,但body.text是json的情况,致rest_client解析json报错,加了try/catch做处理 --- vnpy/api/rest/rest_client.py | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/vnpy/api/rest/rest_client.py b/vnpy/api/rest/rest_client.py index 1af29631..ce2fb60a 100644 --- a/vnpy/api/rest/rest_client.py +++ b/vnpy/api/rest/rest_client.py @@ -49,10 +49,6 @@ class Request(object): self.response = None self.status = RequestStatus.ready - self.json=None - - def set_json(self, json_str: dict): - self.json=json_str def __str__(self): if self.response is None: @@ -65,7 +61,6 @@ class Request(object): "headers: {}\n" "params: {}\n" "data: {}\n" - "json: {}\n" "response:" "{}\n".format( self.method, @@ -75,7 +70,6 @@ class Request(object): self.headers, self.params, self.data, - self.json, "" if self.response is None else self.response.text, ) ) @@ -151,7 +145,6 @@ class RestClient(object): on_failed: Callable = None, on_error: Callable = None, extra: Any = None, - json_str: dict = None, ): """ Add a new request. @@ -177,8 +170,6 @@ class RestClient(object): on_error, extra, ) - if json_str is not None: - request.set_json(json_str) self._queue.put(request) return request @@ -262,7 +253,6 @@ class RestClient(object): headers=request.headers, params=request.params, data=request.data, - json=request.json, proxies=self.proxies, ) request.response = response