HedgeTech 0.2.0b1__py3-none-any.whl → 0.2.2b0__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.
- HedgeTech/Auth/__AuthAsyncClient.py +16 -12
- HedgeTech/Auth/__AuthSyncClient.py +18 -14
- HedgeTech/Auth/__utils/__RetriableAsyncClient.py +63 -0
- HedgeTech/Auth/__utils/__RetriableSyncClient.py +65 -0
- HedgeTech/Auth/__utils/__init__.py +2 -0
- HedgeTech/EmsEngine/__init__.py +1 -1
- HedgeTech/EmsEngine/__tse_ifb/__AsyncClient.py +543 -249
- HedgeTech/EmsEngine/__tse_ifb/__SyncClient.py +568 -245
- HedgeTech/EmsEngine/__tse_ifb/__init__.py +1 -1
- HedgeTech/EmsEngine/__tse_ifb/__io_types/__response.py +1 -1
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/METADATA +91 -9
- hedgetech-0.2.2b0.dist-info/RECORD +24 -0
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/WHEEL +1 -1
- hedgetech-0.2.0b1.dist-info/RECORD +0 -21
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/licenses/LICENSE +0 -0
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/licenses/NOTICE +0 -0
- {hedgetech-0.2.0b1.dist-info → hedgetech-0.2.2b0.dist-info}/top_level.txt +0 -0
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# Imports #
|
|
3
3
|
# ========================================|======================================== #
|
|
4
4
|
|
|
5
|
+
from .__utils import RetriableAsyncClient
|
|
5
6
|
from httpx import (
|
|
6
7
|
AsyncClient ,
|
|
7
8
|
Timeout ,
|
|
@@ -126,20 +127,23 @@ class AuthAsyncClient:
|
|
|
126
127
|
headers = {'origin' : 'https://core.hedgetech.ir'}
|
|
127
128
|
headers.update(token)
|
|
128
129
|
|
|
129
|
-
httpx_Client =
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
130
|
+
httpx_Client = RetriableAsyncClient(
|
|
131
|
+
client = AsyncClient(
|
|
132
|
+
verify=True ,
|
|
133
|
+
http1=False ,
|
|
134
|
+
http2=True ,
|
|
135
|
+
headers=headers,
|
|
136
|
+
cookies=httpx_Client.cookies,
|
|
137
|
+
timeout=Timeout(
|
|
138
|
+
connect=.250,
|
|
139
|
+
read=1.5,
|
|
140
|
+
write=1.5,
|
|
141
|
+
pool=.250,
|
|
142
|
+
),
|
|
140
143
|
),
|
|
144
|
+
retries= 10
|
|
141
145
|
)
|
|
142
|
-
|
|
146
|
+
|
|
143
147
|
return cls(
|
|
144
148
|
httpx_Client = httpx_Client,
|
|
145
149
|
token = token
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
# Imports #
|
|
3
3
|
# ========================================|======================================== #
|
|
4
4
|
|
|
5
|
+
from .__utils import RetriableSyncClient
|
|
5
6
|
from httpx import (
|
|
6
7
|
Client ,
|
|
7
8
|
Timeout ,
|
|
@@ -128,24 +129,27 @@ class AuthSyncClient:
|
|
|
128
129
|
token = login_res.json()
|
|
129
130
|
headers = {'origin' : 'https://core.hedgetech.ir'}
|
|
130
131
|
headers.update(token)
|
|
131
|
-
|
|
132
|
-
httpx_Client =
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
132
|
+
|
|
133
|
+
httpx_Client = RetriableSyncClient(
|
|
134
|
+
client = Client(
|
|
135
|
+
verify=True ,
|
|
136
|
+
http1=False ,
|
|
137
|
+
http2=True ,
|
|
138
|
+
headers=headers,
|
|
139
|
+
cookies=httpx_Client.cookies,
|
|
140
|
+
timeout=Timeout(
|
|
141
|
+
connect=.250,
|
|
142
|
+
read=1.5,
|
|
143
|
+
write=1.5,
|
|
144
|
+
pool=.250,
|
|
145
|
+
),
|
|
143
146
|
),
|
|
147
|
+
retries= 10
|
|
144
148
|
)
|
|
145
|
-
|
|
149
|
+
|
|
146
150
|
return cls(
|
|
147
151
|
httpx_Client = httpx_Client,
|
|
148
|
-
token =
|
|
152
|
+
token = token
|
|
149
153
|
)
|
|
150
154
|
|
|
151
155
|
else :
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# ========================================|======================================== #
|
|
2
|
+
# Exports #
|
|
3
|
+
# ========================================|======================================== #
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
'RetriableAsyncClient'
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
# ========================================|======================================== #
|
|
10
|
+
# Imports #
|
|
11
|
+
# ========================================|======================================== #
|
|
12
|
+
|
|
13
|
+
from httpx import (
|
|
14
|
+
AsyncClient,
|
|
15
|
+
|
|
16
|
+
ConnectTimeout,
|
|
17
|
+
PoolTimeout,
|
|
18
|
+
ReadTimeout,
|
|
19
|
+
WriteTimeout,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# ========================================|======================================== #
|
|
23
|
+
# Class Definitions #
|
|
24
|
+
# ========================================|======================================== #
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RetriableAsyncClient:
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
client: AsyncClient,
|
|
32
|
+
retries: int = 10,
|
|
33
|
+
)-> AsyncClient:
|
|
34
|
+
|
|
35
|
+
self._client = client
|
|
36
|
+
self._retries = retries
|
|
37
|
+
|
|
38
|
+
async def _request(self, method: str, **kwargs):
|
|
39
|
+
attempt = self._retries
|
|
40
|
+
|
|
41
|
+
while True:
|
|
42
|
+
try:
|
|
43
|
+
return await getattr(self._client, method)(**kwargs)
|
|
44
|
+
|
|
45
|
+
except (
|
|
46
|
+
ConnectTimeout,
|
|
47
|
+
PoolTimeout,
|
|
48
|
+
ReadTimeout,
|
|
49
|
+
WriteTimeout,
|
|
50
|
+
):
|
|
51
|
+
if attempt <= 0:
|
|
52
|
+
raise
|
|
53
|
+
attempt -= 1
|
|
54
|
+
|
|
55
|
+
def __getattr__(self, name: str):
|
|
56
|
+
attr = getattr(self._client, name)
|
|
57
|
+
|
|
58
|
+
if name in {"get", "post", "put", "delete", "patch", "options", "head"}:
|
|
59
|
+
async def wrapper(**kwargs):
|
|
60
|
+
return await self._request(name, **kwargs)
|
|
61
|
+
return wrapper
|
|
62
|
+
|
|
63
|
+
return attr
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# ========================================|======================================== #
|
|
2
|
+
# Exports #
|
|
3
|
+
# ========================================|======================================== #
|
|
4
|
+
|
|
5
|
+
__all__ = [
|
|
6
|
+
'RetriableSyncClient'
|
|
7
|
+
]
|
|
8
|
+
|
|
9
|
+
# ========================================|======================================== #
|
|
10
|
+
# Imports #
|
|
11
|
+
# ========================================|======================================== #
|
|
12
|
+
|
|
13
|
+
from httpx import (
|
|
14
|
+
Client,
|
|
15
|
+
|
|
16
|
+
ConnectTimeout,
|
|
17
|
+
PoolTimeout,
|
|
18
|
+
ReadTimeout,
|
|
19
|
+
WriteTimeout,
|
|
20
|
+
)
|
|
21
|
+
|
|
22
|
+
# ========================================|======================================== #
|
|
23
|
+
# Class Definitions #
|
|
24
|
+
# ========================================|======================================== #
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
class RetriableSyncClient:
|
|
28
|
+
|
|
29
|
+
def __init__(
|
|
30
|
+
self,
|
|
31
|
+
client: Client,
|
|
32
|
+
retries: int = 10,
|
|
33
|
+
)-> Client:
|
|
34
|
+
|
|
35
|
+
self._client = client
|
|
36
|
+
self._retries = retries
|
|
37
|
+
|
|
38
|
+
def _request(self, method: str, **kwargs):
|
|
39
|
+
attempt = self._retries
|
|
40
|
+
|
|
41
|
+
while True:
|
|
42
|
+
try:
|
|
43
|
+
return getattr(self._client, method)(**kwargs)
|
|
44
|
+
|
|
45
|
+
except (
|
|
46
|
+
ConnectTimeout,
|
|
47
|
+
PoolTimeout,
|
|
48
|
+
ReadTimeout,
|
|
49
|
+
WriteTimeout,
|
|
50
|
+
):
|
|
51
|
+
if attempt <= 0:
|
|
52
|
+
raise
|
|
53
|
+
attempt -= 1
|
|
54
|
+
|
|
55
|
+
def __getattr__(self, name: str):
|
|
56
|
+
|
|
57
|
+
attr = getattr(self._client, name)
|
|
58
|
+
|
|
59
|
+
if name in {"get", "post", "put", "delete", "patch", "options", "head"}:
|
|
60
|
+
|
|
61
|
+
def wrapper(**kwargs):
|
|
62
|
+
return self._request(name, **kwargs)
|
|
63
|
+
return wrapper
|
|
64
|
+
|
|
65
|
+
return attr
|
HedgeTech/EmsEngine/__init__.py
CHANGED