Skip to content

Conversation

@fleming79
Copy link
Owner

The call signature is changed to only accept func,, *args, **kwargs and now also copies the context.

@fleming79 fleming79 added breaking-change A breaking change enhancement New feature or request labels Sep 14, 2025
@codecov-commenter
Copy link

❌ 1 Tests Failed:

Tests completed Failed Passed Skipped
379 1 378 0
View the top 1 failed test(s) by shortest run time
tests/test_debugger.py::test_debugger[async-trio]
Stack Traces | 62.9s run time
delay = 20, shield = False

    @contextmanager
    def fail_after(
        delay: float | None, shield: bool = False
    ) -> Generator[CancelScope, None, None]:
        """
        Create a context manager which raises a :class:`TimeoutError` if does not finish in
        time.
    
        :param delay: maximum allowed time (in seconds) before raising the exception, or
            ``None`` to disable the timeout
        :param shield: ``True`` to shield the cancel scope from external cancellation
        :return: a context manager that yields a cancel scope
        :rtype: :class:`~typing.ContextManager`\\[:class:`~anyio.CancelScope`\\]
    
        """
        current_time = get_async_backend().current_time
        deadline = (current_time() + delay) if delay is not None else math.inf
        with get_async_backend().create_cancel_scope(
            deadline=deadline, shield=shield
        ) as cancel_scope:
>           yield cancel_scope

cancel_scope = <anyio._backends._asyncio.CancelScope object at 0x7f8e1e147f20>
current_time = <bound method AsyncIOBackend.current_time of <class 'anyio._backends._asyncio.AsyncIOBackend'>>
deadline   = 317.945258465
delay      = 20
shield     = False

.venv/lib/python3.12.../anyio/_core/_tasks.py:115: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/utils.py:44: in get_reply
    reply = await client.get_control_msg(timeout=timeout)
            ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        channel    = 'control'
        clear_pub  = True
        client     = <jupyter_client.asynchronous.client.AsyncKernelClient object at 0x7f8e1e9b4ec0>
        msg_id     = '0435c50f-3f11fed36509b94fe3f81e33_2181_14'
        timeout    = 20
.venv/lib/python3.12.../site-packages/jupyter_client/client.py:155: in _async_get_control_msg
    return await ensure_async(self.control_channel.get_msg(*args, **kwargs))
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        args       = ()
        kwargs     = {'timeout': 20}
        self       = <jupyter_client.asynchronous.client.AsyncKernelClient object at 0x7f8e1e9b4ec0>
.venv/lib/python3.12.../jupyter_core/utils/__init__.py:197: in ensure_async
    result = await obj
             ^^^^^^^^^
        obj        = <coroutine object AsyncZMQSocketChannel.get_msg at 0x7f8e1e0da5c0>
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <jupyter_client.channels.AsyncZMQSocketChannel object at 0x7f8e1e1884d0>
timeout = 20

    async def get_msg(  # type:ignore[override]
        self, timeout: t.Optional[float] = None
    ) -> t.Dict[str, t.Any]:
        """Gets a message if there is one that is ready."""
        assert self.socket is not None
        timeout_ms = None if timeout is None else int(timeout * 1000)  # seconds to ms
>       ready = await self.socket.poll(timeout_ms)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
E       asyncio.exceptions.CancelledError: Cancelled by cancel scope 7f8e1e147f20

self       = <jupyter_client.channels.AsyncZMQSocketChannel object at 0x7f8e1e1884d0>
timeout    = 20
timeout_ms = 20000

.venv/lib/python3.12.../site-packages/jupyter_client/channels.py:308: CancelledError

During handling of the above exception, another exception occurred:

subprocess_kernels_client = <jupyter_client.asynchronous.client.AsyncKernelClient object at 0x7f8e1e9b4ec0>

    async def test_debugger(subprocess_kernels_client):
        client = subprocess_kernels_client
>       reply = await send_debug_request(client=client, command="initialize", arguments=initialize_args)
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

client     = <jupyter_client.asynchronous.client.AsyncKernelClient object at 0x7f8e1e9b4ec0>
subprocess_kernels_client = <jupyter_client.asynchronous.client.AsyncKernelClient object at 0x7f8e1e9b4ec0>

tests/test_debugger.py:62: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
tests/test_debugger.py:47: in send_debug_request
    reply = await utils.send_control_message(
        arguments  = {'adapterID': '', 'clientID': 'test-client', 'clientName': 'testClient', 'columnsStartAt1': True, ...}
        client     = <jupyter_client.asynchronous.client.AsyncKernelClient object at 0x7f8e1e9b4ec0>
        command    = 'initialize'
        seq        = 43
tests/utils.py:162: in send_control_message
    return await get_reply(client, msg["header"]["msg_id"], channel="control", clear_pub=clear_pub)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
        clear_pub  = True
        client     = <jupyter_client.asynchronous.client.AsyncKernelClient object at 0x7f8e1e9b4ec0>
        content    = {'arguments': {'adapterID': '', 'clientID': 'test-client', 'clientName': 'testClient', 'columnsStartAt1': True, ...}, 'command': 'initialize', 'seq': 43, 'type': 'request'}
        msg        = {'content': {'arguments': {'adapterID': '', 'clientID': 'test-client', 'clientName': 'testClient', 'columnsStartAt1': ... '0435c50f-3f11fed36509b94fe3f81e33', ...}, 'metadata': {}, 'msg_id': '0435c50f-3f11fed36509b94fe3f81e33_2181_14', ...}
        msg_type   = <MsgType.debug_request: 'debug_request'>
        reply      = True
tests/utils.py:38: in get_reply
    with anyio.fail_after(timeout):
        channel    = 'control'
        clear_pub  = True
        client     = <jupyter_client.asynchronous.client.AsyncKernelClient object at 0x7f8e1e9b4ec0>
        msg_id     = '0435c50f-3f11fed36509b94fe3f81e33_2181_14'
        timeout    = 20
.../usr/lib/python3.12/contextlib.py:158: in __exit__
    self.gen.throw(value)
        self       = <contextlib._GeneratorContextManager object at 0x7f8e1e147b00>
        traceback  = <traceback object at 0x7f8e18a7a800>
        typ        = <class 'asyncio.exceptions.CancelledError'>
        value      = CancelledError('Cancelled by cancel scope 7f8e1e147f20')
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

delay = 20, shield = False

    @contextmanager
    def fail_after(
        delay: float | None, shield: bool = False
    ) -> Generator[CancelScope, None, None]:
        """
        Create a context manager which raises a :class:`TimeoutError` if does not finish in
        time.
    
        :param delay: maximum allowed time (in seconds) before raising the exception, or
            ``None`` to disable the timeout
        :param shield: ``True`` to shield the cancel scope from external cancellation
        :return: a context manager that yields a cancel scope
        :rtype: :class:`~typing.ContextManager`\\[:class:`~anyio.CancelScope`\\]
    
        """
        current_time = get_async_backend().current_time
        deadline = (current_time() + delay) if delay is not None else math.inf
        with get_async_backend().create_cancel_scope(
            deadline=deadline, shield=shield
        ) as cancel_scope:
            yield cancel_scope
    
        if cancel_scope.cancelled_caught and current_time() >= cancel_scope.deadline:
>           raise TimeoutError
E           TimeoutError

cancel_scope = <anyio._backends._asyncio.CancelScope object at 0x7f8e1e147f20>
current_time = <bound method AsyncIOBackend.current_time of <class 'anyio._backends._asyncio.AsyncIOBackend'>>
deadline   = 317.945258465
delay      = 20
shield     = False

.venv/lib/python3.12.../anyio/_core/_tasks.py:118: TimeoutError

To view more test analytics, go to the Test Analytics Dashboard
📋 Got 3 mins? Take this short survey to help us improve Test Analytics.

@fleming79 fleming79 merged commit c680225 into main Sep 14, 2025
28 of 30 checks passed
@fleming79 fleming79 deleted the feature branch September 14, 2025 11:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

breaking-change A breaking change enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants