bitget 0.0.67__py3-none-any.whl → 0.0.70__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- bitget/ccxt/__init__.py +1 -1
- bitget/ccxt/abstract/bitget.py +58 -0
- bitget/ccxt/async_support/__init__.py +1 -1
- bitget/ccxt/async_support/base/exchange.py +6 -3
- bitget/ccxt/async_support/base/ws/client.py +173 -64
- bitget/ccxt/async_support/base/ws/future.py +23 -50
- bitget/ccxt/async_support/bitget.py +469 -147
- bitget/ccxt/base/exchange.py +20 -8
- bitget/ccxt/bitget.py +469 -147
- bitget/ccxt/pro/__init__.py +1 -127
- {bitget-0.0.67.dist-info → bitget-0.0.70.dist-info}/METADATA +61 -1
- {bitget-0.0.67.dist-info → bitget-0.0.70.dist-info}/RECORD +13 -14
- bitget/ccxt/async_support/base/ws/aiohttp_client.py +0 -147
- {bitget-0.0.67.dist-info → bitget-0.0.70.dist-info}/WHEEL +0 -0
bitget/ccxt/pro/__init__.py
CHANGED
@@ -8,7 +8,7 @@ sys.modules['ccxt'] = ccxt_module
|
|
8
8
|
|
9
9
|
# ----------------------------------------------------------------------------
|
10
10
|
|
11
|
-
__version__ = '4.4.
|
11
|
+
__version__ = '4.4.91'
|
12
12
|
|
13
13
|
# ----------------------------------------------------------------------------
|
14
14
|
|
@@ -60,132 +60,6 @@ from ccxt.base.errors import UnsubscribeError # noqa: F4
|
|
60
60
|
from ccxt.base.errors import error_hierarchy # noqa: F401
|
61
61
|
# DO_NOT_REMOVE__ERROR_IMPORTS_END
|
62
62
|
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
63
|
from ccxt.pro.bitget import bitget # noqa: F401
|
190
64
|
|
191
65
|
exchanges = [ 'bitget',]
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.4
|
2
2
|
Name: bitget
|
3
|
-
Version: 0.0.
|
3
|
+
Version: 0.0.70
|
4
4
|
Summary: bitget crypto exchange api client
|
5
5
|
Project-URL: Homepage, https://github.com/ccxt/ccxt
|
6
6
|
Project-URL: Issues, https://github.com/ccxt/ccxt
|
@@ -141,6 +141,7 @@ You can also construct custom requests to available "implicit" endpoints
|
|
141
141
|
- `fetch_convert_trade_history(self, code: Str = None, since: Int = None, limit: Int = None, params={})`
|
142
142
|
- `fetch_cross_borrow_rate(self, code: str, params={})`
|
143
143
|
- `fetch_currencies(self, params={})`
|
144
|
+
- `fetch_default_markets(self, params)`
|
144
145
|
- `fetch_deposit_address(self, code: str, params={})`
|
145
146
|
- `fetch_deposit_withdraw_fees(self, codes: Strings = None, params={})`
|
146
147
|
- `fetch_deposits(self, code: Str = None, since: Int = None, limit: Int = None, params={})`
|
@@ -174,6 +175,7 @@ You can also construct custom requests to available "implicit" endpoints
|
|
174
175
|
- `fetch_trading_fee(self, symbol: str, params={})`
|
175
176
|
- `fetch_trading_fees(self, params={})`
|
176
177
|
- `fetch_transfers(self, code: Str = None, since: Int = None, limit: Int = None, params={})`
|
178
|
+
- `fetch_uta_markets(self, params)`
|
177
179
|
- `fetch_withdrawals(self, code: Str = None, since: Int = None, limit: Int = None, params={})`
|
178
180
|
- `add_margin(self, symbol: str, amount: float, params={})`
|
179
181
|
- `borrow_cross_margin(self, code: str, amount: float, params={})`
|
@@ -275,6 +277,20 @@ You can also construct custom requests to available "implicit" endpoints
|
|
275
277
|
- `public_margin_get_v2_margin_market_long_short_ratio(request)`
|
276
278
|
- `public_earn_get_v2_earn_loan_public_coininfos(request)`
|
277
279
|
- `public_earn_get_v2_earn_loan_public_hour_interest(request)`
|
280
|
+
- `public_uta_get_v3_market_instruments(request)`
|
281
|
+
- `public_uta_get_v3_market_tickers(request)`
|
282
|
+
- `public_uta_get_v3_market_orderbook(request)`
|
283
|
+
- `public_uta_get_v3_market_fills(request)`
|
284
|
+
- `public_uta_get_v3_market_open_interest(request)`
|
285
|
+
- `public_uta_get_v3_market_candles(request)`
|
286
|
+
- `public_uta_get_v3_market_history_candles(request)`
|
287
|
+
- `public_uta_get_v3_market_current_fund_rate(request)`
|
288
|
+
- `public_uta_get_v3_market_history_fund_rate(request)`
|
289
|
+
- `public_uta_get_v3_market_risk_reserve(request)`
|
290
|
+
- `public_uta_get_v3_market_discount_rate(request)`
|
291
|
+
- `public_uta_get_v3_market_margin_loans(request)`
|
292
|
+
- `public_uta_get_v3_market_position_tier(request)`
|
293
|
+
- `public_uta_get_v3_market_oi_limit(request)`
|
278
294
|
- `private_spot_get_spot_v1_wallet_deposit_address(request)`
|
279
295
|
- `private_spot_get_spot_v1_wallet_withdrawal_list(request)`
|
280
296
|
- `private_spot_get_spot_v1_wallet_deposit_list(request)`
|
@@ -706,6 +722,50 @@ You can also construct custom requests to available "implicit" endpoints
|
|
706
722
|
- `private_earn_post_v2_earn_loan_repay(request)`
|
707
723
|
- `private_earn_post_v2_earn_loan_revise_pledge(request)`
|
708
724
|
- `private_common_get_v2_common_trade_rate(request)`
|
725
|
+
- `private_uta_get_v3_account_assets(request)`
|
726
|
+
- `private_uta_get_v3_account_settings(request)`
|
727
|
+
- `private_uta_get_v3_account_financial_records(request)`
|
728
|
+
- `private_uta_get_v3_account_repayable_coins(request)`
|
729
|
+
- `private_uta_get_v3_account_payment_coins(request)`
|
730
|
+
- `private_uta_get_v3_account_convert_records(request)`
|
731
|
+
- `private_uta_get_v3_account_transferable_coins(request)`
|
732
|
+
- `private_uta_get_v3_account_sub_transfer_record(request)`
|
733
|
+
- `private_uta_get_v3_ins_loan_transfered(request)`
|
734
|
+
- `private_uta_get_v3_ins_loan_symbols(request)`
|
735
|
+
- `private_uta_get_v3_ins_loan_risk_unit(request)`
|
736
|
+
- `private_uta_get_v3_ins_loan_repaid_history(request)`
|
737
|
+
- `private_uta_get_v3_ins_loan_product_infos(request)`
|
738
|
+
- `private_uta_get_v3_ins_loan_loan_order(request)`
|
739
|
+
- `private_uta_get_v3_ins_loan_ltv_convert(request)`
|
740
|
+
- `private_uta_get_v3_ins_loan_ensure_coins_convert(request)`
|
741
|
+
- `private_uta_get_v3_position_current_position(request)`
|
742
|
+
- `private_uta_get_v3_position_history_position(request)`
|
743
|
+
- `private_uta_get_v3_trade_order_info(request)`
|
744
|
+
- `private_uta_get_v3_trade_unfilled_orders(request)`
|
745
|
+
- `private_uta_get_v3_trade_history_orders(request)`
|
746
|
+
- `private_uta_get_v3_trade_fills(request)`
|
747
|
+
- `private_uta_get_v3_user_sub_list(request)`
|
748
|
+
- `private_uta_get_v3_user_sub_api_list(request)`
|
749
|
+
- `private_uta_post_v3_account_set_leverage(request)`
|
750
|
+
- `private_uta_post_v3_account_set_hold_mode(request)`
|
751
|
+
- `private_uta_post_v3_account_repay(request)`
|
752
|
+
- `private_uta_post_v3_account_transfer(request)`
|
753
|
+
- `private_uta_post_v3_account_sub_transfer(request)`
|
754
|
+
- `private_uta_post_v3_account_max_open_available(request)`
|
755
|
+
- `private_uta_post_v3_ins_loan_bind_uid(request)`
|
756
|
+
- `private_uta_post_v3_trade_place_order(request)`
|
757
|
+
- `private_uta_post_v3_trade_modify_order(request)`
|
758
|
+
- `private_uta_post_v3_trade_cancel_order(request)`
|
759
|
+
- `private_uta_post_v3_trade_place_batch(request)`
|
760
|
+
- `private_uta_post_v3_trade_batch_modify_order(request)`
|
761
|
+
- `private_uta_post_v3_trade_cancel_batch(request)`
|
762
|
+
- `private_uta_post_v3_trade_cancel_symbol_order(request)`
|
763
|
+
- `private_uta_post_v3_trade_close_positions(request)`
|
764
|
+
- `private_uta_post_v3_user_create_sub(request)`
|
765
|
+
- `private_uta_post_v3_user_freeze_sub(request)`
|
766
|
+
- `private_uta_post_v3_user_create_sub_api(request)`
|
767
|
+
- `private_uta_post_v3_user_update_sub_api(request)`
|
768
|
+
- `private_uta_post_v3_user_delete_sub_api(request)`
|
709
769
|
|
710
770
|
### WS Unified
|
711
771
|
|
@@ -1,27 +1,26 @@
|
|
1
1
|
bitget/__init__.py,sha256=D5tG1_AjwXjMim3CPnCuWSheOXtq4vlSwVCS5ZG1bMQ,246
|
2
|
-
bitget/ccxt/__init__.py,sha256=
|
3
|
-
bitget/ccxt/bitget.py,sha256=
|
4
|
-
bitget/ccxt/abstract/bitget.py,sha256=
|
5
|
-
bitget/ccxt/async_support/__init__.py,sha256=
|
6
|
-
bitget/ccxt/async_support/bitget.py,sha256=
|
2
|
+
bitget/ccxt/__init__.py,sha256=gHtrCEQyU3T-l4mb0f_1rBrWsvS9YqHe-XJJMF3fZqY,6048
|
3
|
+
bitget/ccxt/bitget.py,sha256=e6ssz20PaoHGhU9bL0fDs4q54HGB-_BkssQGelOOW_0,453846
|
4
|
+
bitget/ccxt/abstract/bitget.py,sha256=6q34nW4J1Vfvls4tExxZRJt0Ct28hCO0TQja_Mb_bmI,99978
|
5
|
+
bitget/ccxt/async_support/__init__.py,sha256=7kJ1lJApC3lQB5ru5ogMxqpOojNzMuwp9PeHW1wzQUw,4781
|
6
|
+
bitget/ccxt/async_support/bitget.py,sha256=sPHtswNgPICInGQshCx2B1FxTmzf71mHVFQIxImZeew,455589
|
7
7
|
bitget/ccxt/async_support/base/__init__.py,sha256=aVYSsFi--b4InRs9zDN_wtCpj8odosAB726JdUHavrk,67
|
8
|
-
bitget/ccxt/async_support/base/exchange.py,sha256=
|
8
|
+
bitget/ccxt/async_support/base/exchange.py,sha256=RBB3v5Eqi6U0twVnaocSBCk0MD87meBQdYIz_mGCRUs,119286
|
9
9
|
bitget/ccxt/async_support/base/throttler.py,sha256=tvDVcdRUVYi8fZRlEcnqtgzcgB_KMUMRs5Pu8tuU-tU,1847
|
10
10
|
bitget/ccxt/async_support/base/ws/__init__.py,sha256=uockzpLuwntKGZbs5EOWFe-Zg-k6Cj7GhNJLc_RX0so,1791
|
11
|
-
bitget/ccxt/async_support/base/ws/aiohttp_client.py,sha256=Y5HxAVXyyYduj6b6SbbUZETlq3GrVMzrkW1r-TMgpb8,6329
|
12
11
|
bitget/ccxt/async_support/base/ws/cache.py,sha256=xf2VOtfUwloxSlIQ39M1RGZHWQzyS9IGhB5NX6cDcAc,8370
|
13
|
-
bitget/ccxt/async_support/base/ws/client.py,sha256=
|
12
|
+
bitget/ccxt/async_support/base/ws/client.py,sha256=3H6NnHk7GIC6wqJ49eshuvy5MnT3ma4cnAPSWKNy6S8,13475
|
14
13
|
bitget/ccxt/async_support/base/ws/functions.py,sha256=qwvEnjtINWL5ZU-dbbeIunjyBxzFqbGWHfVhxqAcKug,1499
|
15
|
-
bitget/ccxt/async_support/base/ws/future.py,sha256=
|
14
|
+
bitget/ccxt/async_support/base/ws/future.py,sha256=9yFyxqT7cl-7ZFM6LM4b6UPXyO2FGIbAhs5uoJ3-Smo,1271
|
16
15
|
bitget/ccxt/async_support/base/ws/order_book.py,sha256=uBUaIHhzMRykpmo4BCsdJ-t_HozS6VxhEs8x-Kbj-NI,2894
|
17
16
|
bitget/ccxt/async_support/base/ws/order_book_side.py,sha256=GhnGUt78pJ-AYL_Dq9produGjmBJLCI5FHIRdMz1O-g,6551
|
18
17
|
bitget/ccxt/base/__init__.py,sha256=eTx1OE3HJjspFUQjGm6LBhaQiMKJnXjkdP-JUXknyQ0,1320
|
19
18
|
bitget/ccxt/base/decimal_to_precision.py,sha256=fgWRBzRTtsf3r2INyS4f7WHlzgjB5YM1ekiwqD21aac,6634
|
20
19
|
bitget/ccxt/base/errors.py,sha256=MvCrL_sAM3de616T6RE0PSxiF2xV6Qqz5b1y1ghidbk,4888
|
21
|
-
bitget/ccxt/base/exchange.py,sha256=
|
20
|
+
bitget/ccxt/base/exchange.py,sha256=wjO_dKXa2T3CqHP7jZtL7grD_tifCcNn_wew8PNCotc,328697
|
22
21
|
bitget/ccxt/base/precise.py,sha256=koce64Yrp6vFbGijJtUt-QQ6XhJgeGTCksZ871FPp_A,8886
|
23
22
|
bitget/ccxt/base/types.py,sha256=IbLO7Ni-plO36xlOdJQFqujSJBq0q9qll009ShZ0M_U,11468
|
24
|
-
bitget/ccxt/pro/__init__.py,sha256=
|
23
|
+
bitget/ccxt/pro/__init__.py,sha256=TCiEhsY7Khvua2nhaBzQoV6IvEL-Lhvy2cjUjFeY5rA,4095
|
25
24
|
bitget/ccxt/pro/bitget.py,sha256=g8SkdhTze-idsChWiGIBi1twpiDfRlJyvnG2NL9VsR0,90372
|
26
25
|
bitget/ccxt/static_dependencies/README.md,sha256=3TCvhhn09_Cqf9BDDpao1V7EfKHDpQ6k9oWRsLFixpU,18
|
27
26
|
bitget/ccxt/static_dependencies/__init__.py,sha256=tzFje8cloqmiIE6kola3EaYC0SnD1izWnri69hzHsSw,168
|
@@ -282,6 +281,6 @@ bitget/ccxt/static_dependencies/toolz/curried/exceptions.py,sha256=gKFOHDIayAWnX
|
|
282
281
|
bitget/ccxt/static_dependencies/toolz/curried/operator.py,sha256=ML92mknkAwzBl2NCm-4werSUmJEtSHNY9NSzhseNM9s,525
|
283
282
|
bitget/ccxt/static_dependencies/typing_inspect/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
284
283
|
bitget/ccxt/static_dependencies/typing_inspect/typing_inspect.py,sha256=5gIWomLPfuDpgd3gX1GlnX0MuXM3VorR4j2W2qXORiQ,28269
|
285
|
-
bitget-0.0.
|
286
|
-
bitget-0.0.
|
287
|
-
bitget-0.0.
|
284
|
+
bitget-0.0.70.dist-info/METADATA,sha256=adJwtOcN-_EI7HJrB37WXCk3DasFdohI3Y3dXBuGmMw,44111
|
285
|
+
bitget-0.0.70.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
286
|
+
bitget-0.0.70.dist-info/RECORD,,
|
@@ -1,147 +0,0 @@
|
|
1
|
-
# -*- coding: utf-8 -*-
|
2
|
-
|
3
|
-
orjson = None
|
4
|
-
try:
|
5
|
-
import orjson as orjson
|
6
|
-
except ImportError:
|
7
|
-
pass
|
8
|
-
|
9
|
-
import json
|
10
|
-
from asyncio import sleep, ensure_future
|
11
|
-
from aiohttp import WSMsgType
|
12
|
-
from .functions import milliseconds, iso8601, is_json_encoded_object
|
13
|
-
from ccxt.async_support.base.ws.client import Client
|
14
|
-
from ccxt.async_support.base.ws.functions import gunzip, inflate
|
15
|
-
from ccxt import NetworkError, RequestTimeout, ExchangeClosedByUser
|
16
|
-
|
17
|
-
|
18
|
-
class AiohttpClient(Client):
|
19
|
-
|
20
|
-
proxy = None
|
21
|
-
|
22
|
-
def closed(self):
|
23
|
-
return (self.connection is None) or self.connection.closed
|
24
|
-
|
25
|
-
def receive(self):
|
26
|
-
return self.connection.receive()
|
27
|
-
|
28
|
-
# helper method for binary and text messages
|
29
|
-
def handle_text_or_binary_message(self, data):
|
30
|
-
if self.verbose:
|
31
|
-
self.log(iso8601(milliseconds()), 'message', data)
|
32
|
-
if isinstance(data, bytes):
|
33
|
-
data = data.decode()
|
34
|
-
# decoded = json.loads(data) if is_json_encoded_object(data) else data
|
35
|
-
decode = None
|
36
|
-
if is_json_encoded_object(data):
|
37
|
-
if orjson is None:
|
38
|
-
decode = json.loads(data)
|
39
|
-
else:
|
40
|
-
decode = orjson.loads(data)
|
41
|
-
else:
|
42
|
-
decode = data
|
43
|
-
self.on_message_callback(self, decode)
|
44
|
-
|
45
|
-
def handle_message(self, message):
|
46
|
-
# self.log(iso8601(milliseconds()), message)
|
47
|
-
if message.type == WSMsgType.TEXT:
|
48
|
-
self.handle_text_or_binary_message(message.data)
|
49
|
-
elif message.type == WSMsgType.BINARY:
|
50
|
-
data = message.data
|
51
|
-
if self.gunzip:
|
52
|
-
data = gunzip(data)
|
53
|
-
elif self.inflate:
|
54
|
-
data = inflate(data)
|
55
|
-
self.handle_text_or_binary_message(data)
|
56
|
-
# autoping is responsible for automatically replying with pong
|
57
|
-
# to a ping incoming from a server, we have to disable autoping
|
58
|
-
# with aiohttp's websockets and respond with pong manually
|
59
|
-
# otherwise aiohttp's websockets client won't trigger WSMsgType.PONG
|
60
|
-
elif message.type == WSMsgType.PING:
|
61
|
-
if self.verbose:
|
62
|
-
self.log(iso8601(milliseconds()), 'ping', message)
|
63
|
-
ensure_future(self.connection.pong(message.data), loop=self.asyncio_loop)
|
64
|
-
elif message.type == WSMsgType.PONG:
|
65
|
-
self.lastPong = milliseconds()
|
66
|
-
if self.verbose:
|
67
|
-
self.log(iso8601(milliseconds()), 'pong', message)
|
68
|
-
pass
|
69
|
-
elif message.type == WSMsgType.CLOSE:
|
70
|
-
if self.verbose:
|
71
|
-
self.log(iso8601(milliseconds()), 'close', self.closed(), message)
|
72
|
-
self.on_close(message.data)
|
73
|
-
elif message.type == WSMsgType.CLOSED:
|
74
|
-
if self.verbose:
|
75
|
-
self.log(iso8601(milliseconds()), 'closed', self.closed(), message)
|
76
|
-
self.on_close(1000)
|
77
|
-
elif message.type == WSMsgType.ERROR:
|
78
|
-
if self.verbose:
|
79
|
-
self.log(iso8601(milliseconds()), 'error', message)
|
80
|
-
error = NetworkError(str(message))
|
81
|
-
self.on_error(error)
|
82
|
-
|
83
|
-
def create_connection(self, session):
|
84
|
-
# autoping is responsible for automatically replying with pong
|
85
|
-
# to a ping incoming from a server, we have to disable autoping
|
86
|
-
# with aiohttp's websockets and respond with pong manually
|
87
|
-
# otherwise aiohttp's websockets client won't trigger WSMsgType.PONG
|
88
|
-
# call aenter here to simulate async with otherwise we get the error "await not called with future"
|
89
|
-
# if connecting to a non-existent endpoint
|
90
|
-
if (self.proxy):
|
91
|
-
return session.ws_connect(self.url, autoping=False, autoclose=False, headers=self.options.get('headers'), proxy=self.proxy, max_msg_size=10485760).__aenter__()
|
92
|
-
return session.ws_connect(self.url, autoping=False, autoclose=False, headers=self.options.get('headers'), max_msg_size=10485760).__aenter__()
|
93
|
-
|
94
|
-
async def send(self, message):
|
95
|
-
if self.verbose:
|
96
|
-
self.log(iso8601(milliseconds()), 'sending', message)
|
97
|
-
send_msg = None
|
98
|
-
if isinstance(message, str):
|
99
|
-
send_msg = message
|
100
|
-
else:
|
101
|
-
if orjson is None:
|
102
|
-
send_msg = json.dumps(message, separators=(',', ':'))
|
103
|
-
else:
|
104
|
-
send_msg = orjson.dumps(message).decode('utf-8')
|
105
|
-
return await self.connection.send_str(send_msg)
|
106
|
-
|
107
|
-
async def close(self, code=1000):
|
108
|
-
if self.verbose:
|
109
|
-
self.log(iso8601(milliseconds()), 'closing', code)
|
110
|
-
if not self.closed():
|
111
|
-
await self.connection.close()
|
112
|
-
# these will end automatically once self.closed() = True
|
113
|
-
# so we don't need to cancel them
|
114
|
-
if self.ping_looper:
|
115
|
-
self.ping_looper.cancel()
|
116
|
-
if self.receive_looper:
|
117
|
-
self.receive_looper.cancel() # cancel all pending futures stored in self.futures
|
118
|
-
for key in self.futures:
|
119
|
-
future = self.futures[key]
|
120
|
-
if not future.done():
|
121
|
-
if future.is_race_future:
|
122
|
-
future.cancel() # this is an "internal" future so we want to cancel it silently
|
123
|
-
else:
|
124
|
-
future.reject(ExchangeClosedByUser('Connection closed by the user'))
|
125
|
-
|
126
|
-
|
127
|
-
async def ping_loop(self):
|
128
|
-
if self.verbose:
|
129
|
-
self.log(iso8601(milliseconds()), 'ping loop')
|
130
|
-
while self.keepAlive and not self.closed():
|
131
|
-
now = milliseconds()
|
132
|
-
self.lastPong = now if self.lastPong is None else self.lastPong
|
133
|
-
if (self.lastPong + self.keepAlive * self.maxPingPongMisses) < now:
|
134
|
-
self.on_error(RequestTimeout('Connection to ' + self.url + ' timed out due to a ping-pong keepalive missing on time'))
|
135
|
-
# the following ping-clause is not necessary with aiohttp's built-in ws
|
136
|
-
# since it has a heartbeat option (see create_connection above)
|
137
|
-
# however some exchanges require a text-type ping message
|
138
|
-
# therefore we need this clause anyway
|
139
|
-
else:
|
140
|
-
if self.ping:
|
141
|
-
try:
|
142
|
-
await self.send(self.ping(self))
|
143
|
-
except Exception as e:
|
144
|
-
self.on_error(e)
|
145
|
-
else:
|
146
|
-
await self.connection.ping()
|
147
|
-
await sleep(self.keepAlive / 1000)
|
File without changes
|