cafs-cache-cdn-client 1.0.5__py3-none-any.whl → 1.0.7__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.
@@ -1,5 +1,4 @@
1
1
  import asyncio
2
- from asyncio import Queue, QueueShutDown
3
2
  from collections.abc import (
4
3
  AsyncIterator,
5
4
  Callable,
@@ -282,7 +281,8 @@ class ConnectionPool:
282
281
 
283
282
  _lock: asyncio.Lock
284
283
  _connections: set[CAFSConnection]
285
- _connection_queue: Queue[CAFSConnection]
284
+ _connection_queue: asyncio.Queue[CAFSConnection]
285
+ _close_event: asyncio.Event
286
286
 
287
287
  def __init__(
288
288
  self,
@@ -297,8 +297,9 @@ class ConnectionPool:
297
297
  self.connection_per_server = connection_per_server
298
298
 
299
299
  self._connections = set()
300
- self._connection_queue = Queue()
300
+ self._connection_queue = asyncio.Queue()
301
301
  self._lock = asyncio.Lock()
302
+ self._close_event = asyncio.Event()
302
303
 
303
304
  async def get_connection_count(self) -> int:
304
305
  async with self._lock:
@@ -315,10 +316,21 @@ class ConnectionPool:
315
316
  await self._connection_queue.put(conn)
316
317
 
317
318
  async def _get_connection(self) -> CAFSConnection:
318
- try:
319
- return await self._connection_queue.get()
320
- except QueueShutDown as err:
321
- raise EmptyConnectionPoolError() from err
319
+ if self._close_event.is_set():
320
+ raise EmptyConnectionPoolError()
321
+ get_task = asyncio.create_task(self._connection_queue.get())
322
+ close_task = asyncio.create_task(self._close_event.wait())
323
+ _, pending = await asyncio.wait(
324
+ [get_task, close_task], return_when=asyncio.FIRST_COMPLETED
325
+ )
326
+
327
+ for task in pending:
328
+ task.cancel()
329
+
330
+ if get_task in pending:
331
+ raise EmptyConnectionPoolError()
332
+
333
+ return get_task.result()
322
334
 
323
335
  async def _release_connection(self, conn: CAFSConnection) -> None:
324
336
  await self._connection_queue.put(conn)
@@ -328,14 +340,15 @@ class ConnectionPool:
328
340
  async with self._lock:
329
341
  self._connections.remove(conn)
330
342
  if not self._connections:
331
- self._connection_queue.shutdown(immediate=True)
343
+ self._close_event.set()
332
344
 
333
345
  async def close(self) -> None:
334
346
  async with self._lock:
335
- self._connection_queue.shutdown(immediate=True)
347
+ self._close_event.set()
336
348
  for conn in self._connections:
337
349
  if conn.is_connected:
338
350
  await conn.disconnect()
351
+ self._connections.clear()
339
352
 
340
353
  @asynccontextmanager
341
354
  async def connection(self) -> AsyncIterator[CAFSConnection]:
@@ -428,7 +441,6 @@ class CAFSClient:
428
441
  stop_event = asyncio.Event()
429
442
  workers = [asyncio.create_task(worker(stop_event)) for _ in range(len(blobs))]
430
443
  errors = await asyncio.gather(*workers, return_exceptions=True)
431
- files_queue.shutdown(immediate=True)
432
444
 
433
445
  for err in errors:
434
446
  if isinstance(err, Exception):
@@ -508,7 +520,6 @@ class CAFSClient:
508
520
  asyncio.create_task(worker(stop_event)) for _ in range(max_concurrent)
509
521
  ]
510
522
  errors = await asyncio.gather(*workers, return_exceptions=True)
511
- files_queue.shutdown(immediate=True)
512
523
 
513
524
  for err in errors:
514
525
  if isinstance(err, Exception):
@@ -40,9 +40,10 @@ class LocalFile:
40
40
 
41
41
  def walk(directory: Path) -> list[LocalFile]:
42
42
  results = []
43
- for root, _, files in directory.walk():
43
+ for root, _, files in os.walk(str(directory)):
44
+ root_ = Path(root)
44
45
  for file in files:
45
- file_ = root / file
46
+ file_ = root_ / file
46
47
  file_stat = file_.stat()
47
48
  results.append(
48
49
  LocalFile(
@@ -82,7 +82,7 @@ class RepoClient:
82
82
 
83
83
  async def tag_ref(self, repo: str, ref: str, tag: str) -> None:
84
84
  await self._request(
85
- f'/repository/{repo}/{ref}/tag', method=HTTPMethod.PUT, data={'tag': tag}
85
+ f'/repository/{repo}/{ref}/tag', method=HTTPMethod.POST, data={'tag': tag}
86
86
  )
87
87
 
88
88
  async def post_ref_info(self, repo: str, ref: str, data: dt.RefInfoBody) -> None:
@@ -1,13 +1,13 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: cafs-cache-cdn-client
3
- Version: 1.0.5
3
+ Version: 1.0.7
4
4
  Summary: Async Cache CDN client implementation
5
5
  Keywords: cafs,cache
6
6
  Author: Konstantin Belov
7
7
  Author-email: k.belov@gaijin.team
8
8
  Requires-Python: >=3.11,<4.0
9
9
  Classifier: License :: OSI Approved :: MIT License
10
- Classifier: Development Status :: 5 - Production/Stable
10
+ Classifier: Development Status :: 4 - Beta
11
11
  Classifier: Programming Language :: Python :: 3.11
12
12
  Classifier: Programming Language :: Python :: 3.12
13
13
  Classifier: Programming Language :: Python :: 3.13
@@ -5,14 +5,14 @@ cafs_cache_cdn_client/cafs/blob/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm
5
5
  cafs_cache_cdn_client/cafs/blob/hash_.py,sha256=tI4qenyHnEEtKnNUOq4a25L1GnlKjoieyPGQDoz14rA,736
6
6
  cafs_cache_cdn_client/cafs/blob/package.py,sha256=pOMF5Dw42APHqIlRfcs1YPscqjcbO32Z35aEG0SqoHo,5865
7
7
  cafs_cache_cdn_client/cafs/blob/utils.py,sha256=tqAOvPWIL-sOwXwPiH9Kbsqn5VekJtlf6UO8V9TTtwM,1021
8
- cafs_cache_cdn_client/cafs/client.py,sha256=TJxwc_PFFmSeCxfTjybh--NrCDzuzuxh3Si42Lwm4Tc,18232
8
+ cafs_cache_cdn_client/cafs/client.py,sha256=ebaFivgSQAzS0verVwuzRGZ98pwSEoaiTaUlmL8VB3o,18536
9
9
  cafs_cache_cdn_client/cafs/exceptions.py,sha256=I4E3lFrQ_ysR8gDIh3E0Gz4OMihfLD6vLj_KwKzxnTU,654
10
10
  cafs_cache_cdn_client/cafs/types.py,sha256=q7zqDQ8yKRn-HRSsXDuzawmikAEcyoYQ-_p2WmuDFy4,324
11
11
  cafs_cache_cdn_client/client.py,sha256=d7Dw2U9h8dPYRDPu0mbnXc62SlLy4ruvQk2Alj3cVk8,4584
12
- cafs_cache_cdn_client/file_utils.py,sha256=kDaak0n3emLIn0DXB02yWFkUhYxuLyTmH93WPszKEUQ,2642
12
+ cafs_cache_cdn_client/file_utils.py,sha256=uX5gAc3CUGXpOktD3m_xrz31d4PRnKkq2RkBMqZSe0o,2677
13
13
  cafs_cache_cdn_client/repo/__init__.py,sha256=JzCxKznnLV7WElJuznG_jL2s9tYPecJL5uJRnPZsW5M,58
14
- cafs_cache_cdn_client/repo/client.py,sha256=FEiLefNmvJKwA2gz6dj2gcvt3uKRzLqBARGy4dvXP98,3545
14
+ cafs_cache_cdn_client/repo/client.py,sha256=cxZ6PLwqKG0tIbAXYacpd_eB_TE31-u506q2JyjOenY,3546
15
15
  cafs_cache_cdn_client/repo/datatypes.py,sha256=aTlzFoEibfAOQTqcsg-RmFjnwenS_rBCEMKtN6glOhY,531
16
- cafs_cache_cdn_client-1.0.5.dist-info/METADATA,sha256=m-dhAfuTdQz97XW280baoDd2vZDxEQW0dtJF-eLqbFI,3679
17
- cafs_cache_cdn_client-1.0.5.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
18
- cafs_cache_cdn_client-1.0.5.dist-info/RECORD,,
16
+ cafs_cache_cdn_client-1.0.7.dist-info/METADATA,sha256=8Bgg1yCjjO5LCpRiX0IaJ6G7RuMhzmGlJp_xu0mtZLA,3666
17
+ cafs_cache_cdn_client-1.0.7.dist-info/WHEEL,sha256=fGIA9gx4Qxk2KDKeNJCbOEwSrmLtjWCwzBz351GyrPQ,88
18
+ cafs_cache_cdn_client-1.0.7.dist-info/RECORD,,