diff options
author | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-04 12:02:50 +0200 |
---|---|---|
committer | Ismaël Bouya <ismael.bouya@normalesup.org> | 2018-04-04 12:50:34 +0200 |
commit | d8e233ac11edac1481f0315e25f79b0390c45e29 (patch) | |
tree | 6872b4a8f25e276cbc8877a2de9c1caead5a2d81 /ccxt_wrapper.py | |
parent | 90d7423eec074a0ed0af680c223180f8d7e1d4e6 (diff) | |
download | Trader-d8e233ac11edac1481f0315e25f79b0390c45e29.tar.gz Trader-d8e233ac11edac1481f0315e25f79b0390c45e29.tar.zst Trader-d8e233ac11edac1481f0315e25f79b0390c45e29.zip |
Log http requests exceptions
Diffstat (limited to 'ccxt_wrapper.py')
-rw-r--r-- | ccxt_wrapper.py | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/ccxt_wrapper.py b/ccxt_wrapper.py index 260d49d..bedf84b 100644 --- a/ccxt_wrapper.py +++ b/ccxt_wrapper.py | |||
@@ -3,6 +3,8 @@ import decimal | |||
3 | import time | 3 | import time |
4 | from retry.api import retry_call | 4 | from retry.api import retry_call |
5 | import re | 5 | import re |
6 | from requests.exceptions import RequestException | ||
7 | from ssl import SSLError | ||
6 | 8 | ||
7 | def _cw_exchange_sum(self, *args): | 9 | def _cw_exchange_sum(self, *args): |
8 | return sum([arg for arg in args if isinstance(arg, (float, int, decimal.Decimal))]) | 10 | return sum([arg for arg in args if isinstance(arg, (float, int, decimal.Decimal))]) |
@@ -45,10 +47,16 @@ class poloniexE(poloniex): | |||
45 | self.session._parent = self | 47 | self.session._parent = self |
46 | 48 | ||
47 | def request_wrap(self, *args, **kwargs): | 49 | def request_wrap(self, *args, **kwargs): |
48 | r = self.origin_request(*args, **kwargs) | 50 | try: |
49 | self._parent._market.report.log_http_request(args[0], | 51 | r = self.origin_request(*args, **kwargs) |
50 | args[1], kwargs["data"], kwargs["headers"], r) | 52 | self._parent._market.report.log_http_request(args[0], |
51 | return r | 53 | args[1], kwargs["data"], kwargs["headers"], r) |
54 | return r | ||
55 | except (SSLError, RequestException) as e: | ||
56 | self._parent._market.report.log_http_request(args[0], | ||
57 | args[1], kwargs["data"], kwargs["headers"], e) | ||
58 | raise e | ||
59 | |||
52 | self.session.request = request_wrap.__get__(self.session, | 60 | self.session.request = request_wrap.__get__(self.session, |
53 | self.session.__class__) | 61 | self.session.__class__) |
54 | 62 | ||