python3-commons 0.20.6__py3-none-any.whl → 0.20.8__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.
python3_commons/auth.py CHANGED
@@ -17,7 +17,9 @@ except ImportError as e:
17
17
  import msgspec
18
18
 
19
19
  logger = logging.getLogger(__name__)
20
- _OIDC_LOCK = threading.Lock()
20
+ _OIDC_CONFIG_LOCK = threading.Lock()
21
+ _OIDC_JWKS_LOCK = threading.Lock()
22
+ _OIDC_SESSION_LOCK = threading.Lock()
21
23
 
22
24
 
23
25
  class TokenData(msgspec.Struct):
@@ -101,7 +103,7 @@ class OIDCClient:
101
103
  if self._session:
102
104
  return self._session
103
105
 
104
- with _OIDC_LOCK:
106
+ with _OIDC_SESSION_LOCK:
105
107
  if self._session:
106
108
  return self._session
107
109
 
@@ -145,7 +147,7 @@ class OIDCClient:
145
147
  if self._config:
146
148
  return self._config
147
149
 
148
- with _OIDC_LOCK:
150
+ with _OIDC_CONFIG_LOCK:
149
151
  if self._config:
150
152
  return self._config
151
153
 
@@ -180,7 +182,7 @@ class OIDCClient:
180
182
  if self._jwks:
181
183
  return self._jwks
182
184
 
183
- with _OIDC_LOCK:
185
+ with _OIDC_JWKS_LOCK:
184
186
  if self._jwks:
185
187
  return self._jwks
186
188
 
@@ -1,4 +1,3 @@
1
- import asyncio
2
1
  import contextlib
3
2
  import logging
4
3
  import time
@@ -159,19 +158,18 @@ class AsyncSessionManager:
159
158
  logger.debug('Acquiring session for %r', name)
160
159
 
161
160
  try:
162
- async with asyncio.timeout(self.pool_acquire_timeout):
163
- async with session_maker() as session:
164
- session_acquired = True
165
- elapsed = time.monotonic() - t0
166
- logger.debug('Session acquired for %r in %.3fs', name, elapsed)
167
-
168
- try:
169
- yield session
170
- except Exception:
171
- logger.exception('Database communication error for %r; rolling back', name)
172
- await session.rollback()
173
-
174
- raise
161
+ async with session_maker() as session:
162
+ session_acquired = True
163
+ elapsed = time.monotonic() - t0
164
+ logger.debug('Session acquired for %r in %.3fs', name, elapsed)
165
+
166
+ try:
167
+ yield session
168
+ except Exception:
169
+ logger.exception('Database communication error for %r; rolling back', name)
170
+ await session.rollback()
171
+
172
+ raise
175
173
  except TimeoutError as e:
176
174
  if session_acquired:
177
175
  raise
@@ -230,10 +228,9 @@ async def is_healthy(
230
228
  t0 = time.monotonic()
231
229
 
232
230
  try:
233
- async with asyncio.timeout(timeout):
234
- async with engine.begin() as conn:
235
- result = await conn.execute(text('SELECT 1'))
236
- healthy = result.scalar() == 1
231
+ async with engine.begin() as conn:
232
+ result = await conn.execute(text('SELECT 1'))
233
+ healthy = result.scalar() == 1
237
234
 
238
235
  elapsed = time.monotonic() - t0
239
236
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: python3-commons
3
- Version: 0.20.6
3
+ Version: 0.20.8
4
4
  Summary: Re-usable Python3 code
5
5
  Author-email: Oleg Korsak <kamikaze.is.waiting.you@gmail.com>
6
6
  License-Expression: GPL-3.0
@@ -2,7 +2,7 @@ python3_commons/__init__.py,sha256=0KgaYU46H_IMKn-BuasoRN3C4Hi45KlkHHoPbU9cwiA,1
2
2
  python3_commons/api_client.py,sha256=yerFJNY_SHhYo9FGLv29oHVIGgeXDNzTzMNfFYZpZ0w,5501
3
3
  python3_commons/async_functools.py,sha256=A2HvwFzZHxOWTp4IQM5UiBY2yg1S_0U1CWra5BWK0gk,9101
4
4
  python3_commons/audit.py,sha256=uGoCwenDJ0Gdwbr_VNOZm5scT8luxW1weprJbbMoHo0,2608
5
- python3_commons/auth.py,sha256=xgI9CNuqAUpYNkXHBWmNi3d0AAEpR5BAepJvPCmArWs,7661
5
+ python3_commons/auth.py,sha256=FruxtIwHCHwxaVeu0bxbqrWXFSdS3suEhOMJlqyI79Q,7761
6
6
  python3_commons/cache.py,sha256=lowiXJqFgFy1Yg86wi9IhuoNqIUGP6nc5eNibmf0dfY,8018
7
7
  python3_commons/conf.py,sha256=1HYtNkNBQc5IIABzhH3kz7GnLeF7rj5aNcOoW8xbEa4,3101
8
8
  python3_commons/exceptions.py,sha256=EGjHZVBnsM6CeBfPMqhL0IPMKjDJ_2-Z-aSPXwq91LE,36
@@ -12,7 +12,7 @@ python3_commons/helpers.py,sha256=d1xdxiOyskwq_rzSprB7e7Fo8Hp0uDlWSmRWFL4vC6A,49
12
12
  python3_commons/object_storage.py,sha256=2l8v1mDB5WWN6jhxH2t5xmHBXaVPRJl0z44wExmlO80,7175
13
13
  python3_commons/permissions.py,sha256=gaMKSWg0MgPQTdP1voll4ItXcblXku9BlD0Lq3Xv64U,1724
14
14
  python3_commons/soap_client.py,sha256=w2lOyhhtkhwiNnHjvir8DfjGBO51XVg5rlDHyuudU2A,7169
15
- python3_commons/db/__init__.py,sha256=V4f9SnQvTYYM_RRqg2-dz6KL6vOmsIrTjS_XbRq2TZ8,9166
15
+ python3_commons/db/__init__.py,sha256=Ze5OtqF-yyD9dY0GNljMX9uZAE9E0aw0XAniwYUkjSM,8983
16
16
  python3_commons/db/helpers.py,sha256=xRpWs4aVkBge6HCLjb6OLSnWc1nlV6rKGyaVhZ_x12w,2001
17
17
  python3_commons/db/models/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  python3_commons/db/models/auth.py,sha256=t6z_0c7l_1eB-CCdnPSV9OzJ_ymgkwD1cLpecNhQgoA,773
@@ -27,9 +27,9 @@ python3_commons/serializers/common.py,sha256=VkA7C6wODvHk0QBXVX_x2JieDstihx3U__U
27
27
  python3_commons/serializers/json.py,sha256=UPkC3ps13x2C_NxwVV-K7Ewp4VjkVHSSUkJVw5k7Wiw,712
28
28
  python3_commons/serializers/msgpack.py,sha256=zESFBX34GsZ8rDu6Zk5V6CLT6P0mPilU0r04Ka6TblI,1474
29
29
  python3_commons/serializers/msgspec.py,sha256=upy5CBmK66-8hYnK5bAM_sZvZY5CAqZmzCw9GIF346I,2988
30
- python3_commons-0.20.6.dist-info/licenses/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
31
- python3_commons-0.20.6.dist-info/licenses/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
32
- python3_commons-0.20.6.dist-info/METADATA,sha256=9f8-MmZZuIedgS73x20SyMDgaHE5A4LksDaO2ZY8Vig,2333
33
- python3_commons-0.20.6.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
34
- python3_commons-0.20.6.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
35
- python3_commons-0.20.6.dist-info/RECORD,,
30
+ python3_commons-0.20.8.dist-info/licenses/AUTHORS.rst,sha256=3R9JnfjfjH5RoPWOeqKFJgxVShSSfzQPIrEr1nxIo9Q,90
31
+ python3_commons-0.20.8.dist-info/licenses/LICENSE,sha256=xxILuojHm4fKQOrMHPSslbyy6WuKAN2RiG74HbrYfzM,34575
32
+ python3_commons-0.20.8.dist-info/METADATA,sha256=JIQ9Wj8LBQMV6QjE7Z3lzyG0JBWHQfrsf_3_AJCtueI,2333
33
+ python3_commons-0.20.8.dist-info/WHEEL,sha256=aeYiig01lYGDzBgS8HxWXOg3uV61G9ijOsup-k9o1sk,91
34
+ python3_commons-0.20.8.dist-info/top_level.txt,sha256=lJI6sCBf68eUHzupCnn2dzG10lH3jJKTWM_hrN1cQ7M,16
35
+ python3_commons-0.20.8.dist-info/RECORD,,