arpakitlib 1.7.56__py3-none-any.whl → 1.7.58__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.
@@ -27,6 +27,7 @@ def sync_make_http_request(
27
27
  proxy_url_: str | None = None,
28
28
  raise_for_status_: bool = False,
29
29
  timeout_: timedelta | float = timedelta(seconds=15).total_seconds(),
30
+ enable_logging_: bool = False,
30
31
  **kwargs
31
32
  ) -> requests.Response:
32
33
  if isinstance(timeout_, float):
@@ -51,16 +52,23 @@ def sync_make_http_request(
51
52
  if "allow_redirects" not in kwargs:
52
53
  kwargs["allow_redirects"] = True
53
54
 
55
+ if enable_logging_:
56
+ _logger.info(f"TRY HTTP {method} {url} {params}")
57
+
54
58
  while True:
55
59
  tries_counter += 1
56
60
  try:
57
- _logger.info(f"{tries_counter}/{max_tries_}. {method} {url} {params}")
58
61
  response = requests.request(**kwargs)
59
62
  if raise_for_status_:
60
63
  response.raise_for_status()
64
+ if enable_logging_:
65
+ _logger.info(f"GOOD TRY HTTP {method} {url} {params}")
61
66
  return response
62
67
  except BaseException as exception:
63
- _logger.warning(f"{tries_counter}/{max_tries_}. {method} {url} {params}, exception={exception}")
68
+ if enable_logging_:
69
+ _logger.warning(
70
+ f"{tries_counter}/{max_tries_}. RETRY {method} {url} {params}, exception={exception}"
71
+ )
64
72
  if tries_counter >= max_tries_:
65
73
  raise exception
66
74
  sync_safe_sleep(timedelta(seconds=0.1).total_seconds())
@@ -77,6 +85,7 @@ async def async_make_http_request(
77
85
  proxy_url_: str | None = None,
78
86
  raise_for_status_: bool = False,
79
87
  timeout_: timedelta | None = timedelta(seconds=15),
88
+ enable_logging_: bool = False,
80
89
  **kwargs
81
90
  ) -> aiohttp.ClientResponse:
82
91
  tries_counter = 0
@@ -96,18 +105,25 @@ async def async_make_http_request(
96
105
  if proxy_url_:
97
106
  proxy_connector = ProxyConnector.from_url(proxy_url_)
98
107
 
108
+ if enable_logging_:
109
+ _logger.info(f"TRY HTTP {method} {url} {params}")
110
+
99
111
  while True:
100
112
  tries_counter += 1
101
113
  try:
102
- _logger.info(f"{tries_counter}/{max_tries_}. {method} {url} {params}")
103
114
  async with aiohttp.ClientSession(connector=proxy_connector) as session:
104
115
  async with session.request(**kwargs) as response:
105
116
  if raise_for_status_:
106
117
  response.raise_for_status()
107
118
  await response.read()
119
+ if enable_logging_:
120
+ _logger.info(f"GOOD TRY HTTP {method} {url} {params}")
108
121
  return response
109
122
  except BaseException as exception:
110
- _logger.warning(f"{tries_counter}/{max_tries_}. {method} {url} {params}, exception={exception}")
123
+ if enable_logging_:
124
+ _logger.warning(
125
+ f"{tries_counter}/{max_tries_}. RETRY HTTP {method} {url} {params}, exception={exception}"
126
+ )
111
127
  if tries_counter >= max_tries_:
112
128
  raise exception
113
129
  await async_safe_sleep(timedelta(seconds=0.1).total_seconds())
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: arpakitlib
3
- Version: 1.7.56
3
+ Version: 1.7.58
4
4
  Summary: arpakitlib
5
5
  Home-page: https://github.com/ARPAKIT-Company/arpakitlib
6
6
  License: Apache-2.0
@@ -149,7 +149,7 @@ arpakitlib/ar_fastapi_util.py,sha256=e4Tgz7sPJk-wqMc2sNsBZ7ZVXo2lMnaOq5WY7CbgvMk
149
149
  arpakitlib/ar_file_storage_in_dir_util.py,sha256=D3e3rGuHoI6xqAA5mVvEpVVpOWY1jyjNsjj2UhyHRbE,3674
150
150
  arpakitlib/ar_file_util.py,sha256=07xCF7paAUP2JUyfpeX0l3N1oCSma7qAcBmrCIZVi3g,452
151
151
  arpakitlib/ar_hash_util.py,sha256=Iqy6KBAOLBQMFLWv676boI5sV7atT2B-fb7aCdHOmIQ,340
152
- arpakitlib/ar_http_request_util.py,sha256=tQ7vxmeNNeIru1OXt9DiRp03_4SvG4v0ew9ibD8EA1A,3863
152
+ arpakitlib/ar_http_request_util.py,sha256=Kp2wKU4wGPsJ6m5sLwCEKWMs3Uqa59SUxhBevU6Gk_s,4328
153
153
  arpakitlib/ar_ip_util.py,sha256=aEAa1Hvobh9DWX7cmBAPLqnXSTiKe2hRk-WJaiKMaI8,1009
154
154
  arpakitlib/ar_json_db_util.py,sha256=CEyhIU4WuNmX5mqwBVYxUKSdpFelXvWmf_tJ1fuxMSE,7187
155
155
  arpakitlib/ar_json_util.py,sha256=GwHDdrBWiJBHSc07Qe0aN1Gp_uM0pYpTwzU9JAgsKAo,972
@@ -174,9 +174,9 @@ arpakitlib/ar_str_util.py,sha256=oCEtQ_TTn35OEz9jCNLjbhopq76JmaifD_iYR-nEJJ4,214
174
174
  arpakitlib/ar_type_util.py,sha256=e6Ch8I_B3FMJMj-fiZvTwtGde4hxSa48fGt5g8RlV6I,2301
175
175
  arpakitlib/ar_yookassa_api_client_util.py,sha256=sh4fcUkAkdOetFn9JYoTvjcSXP-M1wU04KEY-ECLfLg,5137
176
176
  arpakitlib/ar_zabbix_api_client_util.py,sha256=Q-VR4MvoZ9aHwZeYZr9G3LwN-ANx1T5KFmF6pvPM-9M,6402
177
- arpakitlib-1.7.56.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
178
- arpakitlib-1.7.56.dist-info/METADATA,sha256=cofj4tL5_IJTjtTHTUZYFN1qi_xgUDn4twbANtCsXO8,2824
179
- arpakitlib-1.7.56.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
180
- arpakitlib-1.7.56.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
181
- arpakitlib-1.7.56.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
182
- arpakitlib-1.7.56.dist-info/RECORD,,
177
+ arpakitlib-1.7.58.dist-info/LICENSE,sha256=GPEDQMam2r7FSTYqM1mm7aKnxLaWcBotH7UvQtea-ec,11355
178
+ arpakitlib-1.7.58.dist-info/METADATA,sha256=vWO-xc2jInkQXyY_TItpJ0UTbgsGRDbLUfFhiCI0VEw,2824
179
+ arpakitlib-1.7.58.dist-info/NOTICE,sha256=95aUzaPJjVpDsGAsNzVnq7tHTxAl0s5UFznCTkVCau4,763
180
+ arpakitlib-1.7.58.dist-info/WHEEL,sha256=Nq82e9rUAnEjt98J6MlVmMCZb-t9cYE2Ir1kpBmnWfs,88
181
+ arpakitlib-1.7.58.dist-info/entry_points.txt,sha256=36xqR3PJFT2kuwjkM_EqoIy0qFUDPKSm_mJaI7emewE,87
182
+ arpakitlib-1.7.58.dist-info/RECORD,,