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

chore: refactor out unused c_logger constant #489

Merged
merged 2 commits into from
Dec 16, 2024
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
9 changes: 5 additions & 4 deletions a_sync/asyncio/create_task.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@ from a_sync._typing import *

logger = logging.getLogger(__name__)

cdef object c_logger = logger


def create_task(
coro: Awaitable[T],
Expand Down Expand Up @@ -120,6 +118,9 @@ async def __await(awaitable: Awaitable[T]) -> T:
args.append(awaitable._children)
raise RuntimeError(*args) from None


cdef object __log_exception = logger.exception


cdef void __prune_persisted_tasks():
"""Remove completed tasks from the set of persisted tasks.
Expand All @@ -138,7 +139,7 @@ cdef void __prune_persisted_tasks():
if e := _get_exception(task):
# force exceptions related to this lib to bubble up
if not isinstance(e, exceptions.PersistedTaskException):
c_logger.exception(e)
__log_exception(e)
raise e
# we have to manually log the traceback that asyncio would usually log
# since we already got the exception from the task and the usual handler will now not run
Expand Down Expand Up @@ -193,4 +194,4 @@ async def __persisted_task_exc_wrap(task: "asyncio.Task[T]") -> T:
raise exceptions.PersistedTaskException(e, task) from e


__all__ = ["create_task"]
__all__ = ["create_task"]
Loading