python3-commons 0.6.10__py3-none-any.whl → 0.6.11__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.
@@ -3,7 +3,7 @@ from datetime import datetime, UTC
3
3
  from json import dumps
4
4
  from typing import AsyncGenerator, Literal, Mapping, Sequence
5
5
 
6
- from aiohttp import ClientSession
6
+ from aiohttp import ClientSession, client_exceptions
7
7
  from aiohttp.web_response import Response
8
8
  from pydantic import HttpUrl
9
9
 
@@ -49,17 +49,27 @@ async def request(
49
49
  )
50
50
  client_method = getattr(client, method)
51
51
 
52
- if method == 'get':
53
- async with client_method(url, params=query) as response:
54
- yield response
55
- else:
56
- if json:
57
- data = dumps(json, cls=CustomJSONEncoder).encode('utf-8')
52
+ try:
53
+ if method == 'get':
54
+ async with client_method(url, params=query) as response:
55
+ yield response
56
+ else:
57
+ if json:
58
+ data = dumps(json, cls=CustomJSONEncoder).encode('utf-8')
59
+
60
+ if headers:
61
+ headers = {**headers, 'Content-Type': 'application/json'}
62
+ else:
63
+ headers = {'Content-Type': 'application/json'}
58
64
 
59
- if headers:
60
- headers = {**headers, 'Content-Type': 'application/json'}
61
- else:
62
- headers = {'Content-Type': 'application/json'}
65
+ async with client_method(url, params=query, data=data, headers=headers) as response:
66
+ yield response
67
+ except client_exceptions.ClientOSError as e:
68
+ if e.errno == 32:
69
+ raise ConnectionResetError('Broken pipe') from e
70
+ elif e.errno == 104:
71
+ raise ConnectionResetError('Connection reset by peer') from e
63
72
 
64
- async with client_method(url, params=query, data=data, headers=headers) as response:
65
- yield response
73
+ raise
74
+ except client_exceptions.ServerDisconnectedError as e:
75
+ raise ConnectionResetError('Server disconnected') from e
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.2
2
2
  Name: python3-commons
3
- Version: 0.6.10
3
+ Version: 0.6.11
4
4
  Summary: Re-usable Python3 code
5
5
  Author-email: Oleg Korsak <kamikaze.is.waiting.you@gmail.com>
6
6
  License: gpl-3
@@ -1,5 +1,5 @@
1
1
  python3_commons/__init__.py,sha256=0KgaYU46H_IMKn-BuasoRN3C4Hi45KlkHHoPbU9cwiA,189
2
- python3_commons/api_client.py,sha256=bfAy3HoN3Olo5dlhZAm3beTNIcya3mJ4z0vGYQa-vao,2219
2
+ python3_commons/api_client.py,sha256=276acJIbbR4B4dcNxnkktCZRbDr5RxSXuW6qcP-VnE0,2673
3
3
  python3_commons/audit.py,sha256=DMQ-nrWSs0qilD7wkz_8PV4jXcee75O8FgAm2YIuOiY,6256
4
4
  python3_commons/conf.py,sha256=qm2a2yWOhfawicBPjWnUett8TrsMtoyQXDxEJ_N-v-Y,637
5
5
  python3_commons/db.py,sha256=qhaDIdzBWgFyeP_XPKfHZlYVlwS2bpBPYMv84yV6820,738
@@ -13,9 +13,9 @@ python3_commons/serializers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMp
13
13
  python3_commons/serializers/json.py,sha256=P288wWz9ic38QWEMrpp_uwKPYkQiOgvE1cI4WZn6ZCg,808
14
14
  python3_commons/serializers/msgpack.py,sha256=tzIGGyDL3UpZnnouCtnxuYDx6InKM_C3PP1N4PN8wd4,1269
15
15
  python3_commons/serializers/msgspec.py,sha256=FuZVqOLJb0-lEKrs7dtjhwEbHIpfMUk5yu1hD64zRdc,2038
16
- python3_commons-0.6.10.dist-info/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
17
- python3_commons-0.6.10.dist-info/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
18
- python3_commons-0.6.10.dist-info/METADATA,sha256=neGGKla_09MXjhoGJMQt3S1HQARBXaF8YI4etSbEi9c,986
19
- python3_commons-0.6.10.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
- python3_commons-0.6.10.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
21
- python3_commons-0.6.10.dist-info/RECORD,,
16
+ python3_commons-0.6.11.dist-info/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
17
+ python3_commons-0.6.11.dist-info/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
18
+ python3_commons-0.6.11.dist-info/METADATA,sha256=w6HzqM3eTi8aTImOgbckAGIcp2RbFJbbtMhNLHlIE_0,986
19
+ python3_commons-0.6.11.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
20
+ python3_commons-0.6.11.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
21
+ python3_commons-0.6.11.dist-info/RECORD,,