Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: SmartProcessingQueue private method #512

Merged
merged 2 commits into from
Jan 6, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions a_sync/primitives/queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ class ProcessingQueue(_Queue[Tuple[P, "asyncio.Future[V]"]], Generic[P, V]):
_closed: bool = False
"""Indicates whether the queue is closed."""

__slots__ = "func", "num_workers", "_worker_coro"
__slots__ = "func", "num_workers"

def __init__(
self,
Expand Down Expand Up @@ -328,12 +328,12 @@ def __init__(
self._no_futs = not return_data
"""Indicates whether tasks will return data via futures."""

@wraps(func)
async def _worker_coro() -> NoReturn:
"""Worker coroutine for processing tasks."""
return await self.__worker_coro()
# @wraps(func)
# async def _worker_coro() -> NoReturn:
# """Worker coroutine for processing tasks."""
# return await self._worker_coro()

self._worker_coro = _worker_coro
# self._worker_coro = wraps(func)(self._worker_coro)

# NOTE: asyncio defines both this and __str__
def __repr__(self) -> str:
Expand Down Expand Up @@ -494,7 +494,7 @@ def _workers(self) -> "asyncio.Task[NoReturn]":
return task

@log_broken
async def __worker_coro(self) -> NoReturn:
async def _worker_coro(self) -> NoReturn:
"""
The coroutine executed by worker tasks to process the queue.
"""
Expand Down Expand Up @@ -899,7 +899,7 @@ def _get(self):
return args, kwargs, fut()

@log_broken
async def __worker_coro(self) -> NoReturn:
async def _worker_coro(self) -> NoReturn:
"""
Worker coroutine responsible for processing tasks in the queue.

Expand All @@ -909,7 +909,7 @@ async def __worker_coro(self) -> NoReturn:
Any: Exceptions raised during task processing are logged.

Example:
>>> await queue.__worker_coro()
>>> await queue._worker_coro()
"""
get_next_job = self.get
func = self.func
Expand Down