Skip to content

Testsuite: test_interrupt fails on FreeBSD #501

@rhurlin

Description

@rhurlin

I am the maintainer of the FreeBSD port for spyder-kernels[1]. Up to version 2.5.2, the test suite also worked as expected under FreeBSD. A total of 92 tests passed, 6 were skipped and there were 6 warnings. This was mainly due to the fact that Django was not installed.

[1] https://www.freshports.org/devel/py-spyder-kernels

With version 3.0.0 it is similar, but there is now a new error for the section 'test_interrupt' of spyder_kernels/console/tests/test_console_kernel.py:

# make test
[..snip..]
___________________________ test_interrupt _______________________

    def test_interrupt():
        """
        Test that the kernel can be interrupted by calling a comm handler.
        """
        # Command to start the kernel
        cmd = "from spyder_kernels.console import start; start.main()"
        with setup_kernel(cmd) as client:
            kernel_comm = CommBase()
    
            # Create new comm and send the highest protocol
            comm = Comm(kernel_comm._comm_name, client)
            comm.open(data={})
            comm._send_channel = client.control_channel
            kernel_comm._register_comm(comm)
    
            client.execute_interactive("import time", timeout=TIMEOUT)
    
            # Try interrupting loop
            t0 = time.time()
            msg_id = client.execute("for i in range(100): time.sleep(.1)")
            time.sleep(.2)
            # Raise interrupt on control_channel
            kernel_comm.remote_call().raise_interrupt_signal()
            # Wait for shell message
            while True:
                assert time.time() - t0 < 5
                msg = client.get_shell_msg(timeout=TIMEOUT)
                if msg["parent_header"].get("msg_id") != msg_id:
                    # not from my request
                    continue
                break
            assert time.time() - t0 < 5
    
            if os.name == 'nt':
                # Windows doesn't do "interrupting sleep"
                return
    
            # Try interrupting sleep
            t0 = time.time()
            msg_id = client.execute("time.sleep(10)")
            time.sleep(.2)
            # Raise interrupt on control_channel
            kernel_comm.remote_call().raise_interrupt_signal()
            # Wait for shell message
            while True:
                assert time.time() - t0 < 5
                msg = client.get_shell_msg(timeout=TIMEOUT)
                if msg["parent_header"].get("msg_id") != msg_id:
                    # not from my request
                    continue
                break

>           assert time.time() - t0 < 5
E           assert (1725085139.3097377 - 1725085129.246985) < 5
E            +  where 1725085139.3097377 = <built-in function time>()
E            +    where <built-in function time> = time.time
spyder_kernels/console/tests/test_console_kernel.py:1323: AssertionError

This error occurs within test_interrrupt in the second section (#Try interrupt sleep). The time difference <5 is exceeded, in my case the difference is 10.06275. If I set the threshold in the code to a higher value, e.g. <15, the test runs through without errors.

Since I do not have a deeper understanding of this test section myself and cannot judge whether the time difference is actually a problem, I have a few questions that I hope can be answered here:

  • Is exceeding the time difference (<5) really critical?
  • Would it be sufficient for FreeBSD if I raised this threshold, e.g. to a value <15?
  • Is it possible that the test needs to be adapted to FreeBSD in another way and are there any ideas or hints for this?

I would be very happy if I could get some guidance and help here. And I am of course happy to answer any questions. Thanks in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions