spyder-ide / spyder-kernels

Jupyter Kernels for the Spyder console
MIT License
39 stars 40 forks source link

Testsuite: test_dask_multiprocessing fails with Python 3.11 #433

Open juliangilbey opened 1 year ago

juliangilbey commented 1 year ago

A FYI report: with Python 3.11, I'm seeing the following test failure:

__________________________ test_dask_multiprocessing ___________________________

tmpdir = local('/tmp/pytest-of-jdg/pytest-0/test_dask_multiprocessing2')

    @flaky(max_runs=3)
    @pytest.mark.skipif(not PY3,
                        reason="Only meant for Python 3")
    def test_dask_multiprocessing(tmpdir):
        """
        Test that dask multiprocessing works on Python 3.
        """
        # Command to start the kernel
        cmd = "from spyder_kernels.console import start; start.main()"

        with setup_kernel(cmd) as client:
            # Remove all variables
            client.execute("%reset -f")
            client.get_shell_msg(timeout=TIMEOUT)

            # Write multiprocessing code to a file
            # Runs two times to verify that in the second case it doesn't break
            code = """
    from dask.distributed import Client

    if __name__=='__main__':
        client = Client()
        client.close()
        x = 'hello'
    """
            p = tmpdir.join("mp-test.py")
            p.write(code)

            # Run code two times
            client.execute("runfile(r'{}')".format(to_text_string(p)))
            client.get_shell_msg(timeout=TIMEOUT)

            client.execute("runfile(r'{}')".format(to_text_string(p)))
            client.get_shell_msg(timeout=TIMEOUT)

            # Verify that the `x` variable is defined
            client.inspect('x')
            msg = client.get_shell_msg(timeout=TIMEOUT)
            while "found" not in msg['content']:
                msg = client.get_shell_msg(timeout=TIMEOUT)
            content = msg['content']
>           assert content['found']
E           assert False

console/tests/test_console_kernel.py:572: AssertionError

This is with Debian python3-dask version 2022.02.0+dfsg-2 and python3-distributed version 2022.02.0+ds.1-2.

Of course, Python 3.11 is not yet fully supported by debugpy, so this is just letting you know for when you do come to consider Python 3.11!