Skip to content

1 test fails #3265

Description

@yurivict
―――――――――――――――――――――――――――――――――――――――――――――――――――――――― TestHighsPy.test_user_interrupts ――――――――――――――――――――――――――――――――――――――――――――――――――――――――

self = <test_highspy.TestHighsPy testMethod=test_user_interrupts>

    def test_user_interrupts(self):
        N = 8
        h = highspy.Highs()
        h.silent()
    
        x = h.addBinaries(N, N)
        y = np.fliplr(x)
    
        h.addConstrs(x.sum(axis = 0) == 1)  # each col has exactly one queen
        h.addConstrs(x.sum(axis = 1) == 1)  # each row has exactly one queen
    
        h.addConstrs(x.diagonal(k).sum() <= 1 for k in range(-N + 1, N))  # each diagonal has at most one queen
        h.addConstrs(y.diagonal(k).sum() <= 1 for k in range(-N + 1, N))  # each 'reverse' diagonal has at most one queen
    
        h.HandleUserInterrupt = True
        h.startSolve()
        self.assertRaises(Exception, lambda: h.startSolve())
        h.cancelSolve()
        h.wait()
    
        h = self.get_basic_model()
        h.HandleKeyboardInterrupt = True
        self.assertEqual(h.HandleKeyboardInterrupt, True)
        self.assertEqual(h.HandleUserInterrupt, True)
    
        h.solve()
        h.minimize()
        h.maximize()
        h.minimize()
    
        h.joinSolve(h.startSolve())
        h.joinSolve(h.startSolve(), 0)
    
        # replace wait function with Ctrl+C signal
        __tmp_wait = highspy.highs.Highs.wait
        highspy.highs.Highs.wait = lambda self, t: signal.raise_signal(signal.SIGINT)  # type: ignore[assignment]
        h.HandleKeyboardInterrupt = False
    
        self.assertEqual(h.HandleKeyboardInterrupt, False)
        self.assertEqual(h.HandleUserInterrupt, False)
    
>       h.joinSolve(h.startSolve(), 0)

highspy/tests/test_highspy.py:1353: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

self = <highspy.highs.Highs object at 0x3ea9e69b05f0>, solver_thread = <Thread(Thread-56 (__solve), stopped daemon 68895014217744)>
interrupt_limit = 0

    def joinSolve(self, solver_thread: Optional[Thread] = None, interrupt_limit: int = 5) -> Optional[HighsStatus]:
        """
        Waits for the solver to finish. If solver_thread is provided, it will handle KeyboardInterrupts.
    
        Args:
            solver_thread: A Thread object representing the solver thread (optional).
            interrupt_limit: The number of times to allow KeyboardInterrupt before forcing termination (optional).
    
        Returns:
            A HighsStatus object containing the solve status.
        """
        result: Tuple[bool, Optional[HighsStatus]] = (False, None)
    
        if solver_thread is not None and interrupt_limit <= 0:
    
            try:
>               while not result[0]:
                          ^^^^^^^^^
E               TypeError: 'NoneType' object is not subscriptable

../stage/usr/local/lib/python3.12/site-packages/highspy/highs.py:200: TypeError

 highspy/tests/test_highspy.py::TestHighsPy.test_user_interrupts ⨯                                                                  62% ██████▎   

――――――――――――――――――――――――――――――――――――――――――――――― ERROR at setup of TestHighsPy.test_clear_callbacks ―――――――――――――――――――――――――――――――――――――――――――――――

>   ???

uvloop/loop.pyx:3254: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
uvloop/loop.pyx:1290: in uvloop.loop.Loop.call_soon_threadsafe
    ???
uvloop/loop.pyx:673: in uvloop.loop.Loop._append_ready_handle
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   RuntimeError: Event loop is closed

uvloop/loop.pyx:705: RuntimeError

During handling of the above exception, another exception occurred:

self = <Thread(Thread-57 (_do_shutdown), stopped 68895014215696)>

    def _bootstrap_inner(self):
        try:
            self._set_ident()
            self._set_tstate_lock()
            if _HAVE_THREAD_NATIVE_ID:
                self._set_native_id()
            self._started.set()
            with _active_limbo_lock:
                _active[self._ident] = self
                del _limbo[self]
    
            if _trace_hook:
                _sys.settrace(_trace_hook)
            if _profile_hook:
                _sys.setprofile(_profile_hook)
    
            try:
>               self.run()

/usr/local/lib/python3.12/threading.py:1075: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
/usr/local/lib/python3.12/threading.py:1012: in run
    self._target(*self._args, **self._kwargs)
uvloop/loop.pyx:3256: in uvloop.loop.Loop._do_shutdown
    ???
uvloop/loop.pyx:1290: in uvloop.loop.Loop.call_soon_threadsafe
    ???
uvloop/loop.pyx:673: in uvloop.loop.Loop._append_ready_handle
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   RuntimeError: Event loop is closed

uvloop/loop.pyx:705: RuntimeError

The above exception was the direct cause of the following exception:

>       lambda: ihook(item=item, **kwds), when=when, reraise=reraise
                ^^^^^^^^^^^^^^^^^^^^^^^^
    )
E   pytest.PytestUnhandledThreadExceptionWarning: Exception in thread Thread-57 (_do_shutdown)
E   Enable tracemalloc to get traceback where the object was allocated.
E   See https://docs.pytest.org/en/stable/how-to/capture-warnings.html#resource-warnings for more info.

/usr/local/lib/python3.12/site-packages/flaky/flaky_pytest_plugin.py:146: PytestUnhandledThreadExceptionWarning

Version: 1.15.1
Python-3.12
FreeBSD 15.1

Activity

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

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions