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

Testsuite: test_interrupt fails on FreeBSD #501

Open
rhurlin opened this issue Aug 31, 2024 · 2 comments
Open

Testsuite: test_interrupt fails on FreeBSD #501

rhurlin opened this issue Aug 31, 2024 · 2 comments
Milestone

Comments

@rhurlin
Copy link
Contributor

rhurlin commented Aug 31, 2024

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.

@ccordoba12
Copy link
Member

Hey @rhurlin, thanks for reporting. I'm not sure what's really happening in FreeBSD, but I think it's fine if you increase the time diff to 15. It seems there it takes a lot of time to send a SIGINT signal to the kernel to interrupt what's doing.

@ccordoba12 ccordoba12 added this to the v3.0.2 milestone Oct 29, 2024
@ccordoba12
Copy link
Member

ccordoba12 commented Oct 29, 2024

Sorry, I didn't read the test code carefully, but you can see that before the failure it's running time.sleep(10) in the kernel before trying to interrupt that computation.

That's why the time diff needs to be less than 5 secs (or in any case less than 10) to be passed correctly. So that means that sending SIGINT to the kernel is actually not working in FreeBSD.

@ccordoba12 ccordoba12 modified the milestones: v3.0.2, v3.0.3 Dec 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants