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

Pending Kernels and Windows Unit tests #672

Closed
Zsailer opened this issue Jan 20, 2022 · 6 comments
Closed

Pending Kernels and Windows Unit tests #672

Zsailer opened this issue Jan 20, 2022 · 6 comments

Comments

@Zsailer
Copy link
Member

Zsailer commented Jan 20, 2022

Jupyter Server's unit tests involving pending kernels are failing on Windows in CI—I haven't tested locally.

It might take me some time to fix the issue, especially since I don't have a Windows machine. In the meantime, I mentioned in today's Jupyter Server meeting that we temporarily skip these tests in CI.

I'm opening this issue to track/ensure that we don't forget to fix this issue.

@Zsailer
Copy link
Member Author

Zsailer commented Jan 20, 2022

@vidartf, not urgent, but would you mind trying to run Jupyter Server's unit tests with the latest release of jupyter_client and seeing if the tests hang when they reach the pending kernels tests?

@vidartf
Copy link
Member

vidartf commented Jan 27, 2022

Hard to tell, as my entire terminal window closes after running a few tests. I'll try to see if I can narrow down which test(s) are causing this to happen.

@vidartf
Copy link
Member

vidartf commented Jan 27, 2022

The terminal window closing problem seem unrelated/spurious. Some observations on the tests (need to finish for today):

  • Some sessions tests create a lot of these warnings:
    Task was destroyed but it is pending!
    task: <Task pending name='Task-559' coro=<WebSocketProtocol13._receive_frame_loop() running at C:\cleanconda\envs\server-dev\lib\site-packages\tornado\websocket.py:1116> wait_for=<Future pending cb=[IOLoop.add_future.<locals>.<lambda>() at C:\cleanconda\envs\server-dev\lib\site-packages\tornado\ioloop.py:688, <TaskWakeupMethWrapper object at 0x0000026A2FDEDD60>()]> cb=[IOLoop.add_future.<locals>.<lambda>() at C:\cleanconda\envs\server-dev\lib\site-packages\tornado\ioloop.py:688]>
    
  • All the nbconvert tests fail with ValueError: No template sub-directory with name 'lab' found in the following paths:. Even though I did install pip install jupyter-server[test].
  • tests.test_terminal.test_culling always fails.
  • The services.kernels.test_api tests have a tendency to hang the pytest process so it needs to be force killed. I assume these are the tests that you were having issues with. I will do some more runs tomorrow to see if I can narrow things a bit.

@vidartf
Copy link
Member

vidartf commented Jun 22, 2022

Resuming work here, I now see a bunch of these errors in test_authorizer:

_________________ ERROR at setup of test_authorized_requests[True-GET-/api/kernelspecs/{kernelspec}-None] _________________

cls = <class '_pytest.runner.CallInfo'>, func = <function call_runtest_hook.<locals>.<lambda> at 0x0000021B0490BE20>
when = 'setup', reraise = (<class '_pytest.outcomes.Exit'>, <class 'KeyboardInterrupt'>)

    @classmethod
    def from_call(
        cls,
        func: "Callable[[], TResult]",
        when: "Literal['collect', 'setup', 'call', 'teardown']",
        reraise: Optional[
            Union[Type[BaseException], Tuple[Type[BaseException], ...]]
        ] = None,
    ) -> "CallInfo[TResult]":
        excinfo = None
        start = timing.time()
        precise_start = timing.perf_counter()
        try:
>           result: Optional[TResult] = func()

<env-root>\lib\site-packages\_pytest\runner.py:311:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
<env-root>\lib\site-packages\_pytest\runner.py:255: in <lambda>
    lambda: ihook(item=item, **kwds), when=when, reraise=reraise
<env-root>\lib\site-packages\pluggy\_hooks.py:265: in __call__
    return self._hookexec(self.name, self.get_hookimpls(), kwargs, firstresult)
<env-root>\lib\site-packages\pluggy\_manager.py:80: in _hookexec
    return self._inner_hookexec(hook_name, methods, kwargs, firstresult)
<env-root>\lib\site-packages\_pytest\unraisableexception.py:83: in pytest_runtest_setup
    yield from unraisable_exception_runtest_hook()
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

    def unraisable_exception_runtest_hook() -> Generator[None, None, None]:
        with catch_unraisable_exception() as cm:
            yield
            if cm.unraisable:
                if cm.unraisable.err_msg is not None:
                    err_msg = cm.unraisable.err_msg
                else:
                    err_msg = "Exception ignored in"
                msg = f"{err_msg}: {cm.unraisable.object!r}\n\n"
                msg += "".join(
                    traceback.format_exception(
                        cm.unraisable.exc_type,
                        cm.unraisable.exc_value,
                        cm.unraisable.exc_traceback,
                    )
                )
>               warnings.warn(pytest.PytestUnraisableExceptionWarning(msg))
E               pytest.PytestUnraisableExceptionWarning: Exception ignored in: <function Context.__del__ at 0x0000021B015280D0>
E
E               Traceback (most recent call last):
E                 File "<env-root>\lib\site-packages\zmq\sugar\context.py", line 65, in __del__
E                   warnings.warn(
E               ResourceWarning: unclosed context <zmq.asyncio.Context() at 0x21b0492ed40>

<env-root>\lib\site-packages\_pytest\unraisableexception.py:78: PytestUnraisableExceptionWarning

I believe this is telling us two things:

  • Calling warnings.warn in __del__ is not really ok, as depending on the warning filter it might be an exception (and in my case they seem to be causing exceptions).
  • When the ZMQ context is garbage collected it is complaining about not having been closed. I'm not sure if this is expected during test runs?

@blink1073
Copy link
Contributor

Yes, the warning is in pyzmq itself, and is a result of us not properly closing contexts in some cases. Hopefully this will all be resolved as part of ongoing asyncio refactoring, e.g. jupyter/jupyter_client#755

@blink1073
Copy link
Contributor

The only tests we're skipping on Windows currently are related to files or unix sockets, closing as fixed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants