Skip to content

Tests randomly fail due to KeyboardInterrupt #889

@FliegendeWurst

Description

@FliegendeWurst

Bug Description

Tests for version 2.1.0 fail often with errors similar to:

==================================== ERRORS ====================================
_____________ ERROR at teardown of test_03_publish_helper_qos0_v5 ______________
    def fin():
        stop_process(proc)
        if proc.returncode != expected_returncode:
>           raise RuntimeError(f"Client {name} exited with code {proc.returncode}, expected {expected_returncode}")
E           RuntimeError: Client 03-publish-helper-qos0-v5.py exited with code -2, expected 0
tests/lib/conftest.py:75: RuntimeError
--------------------------- Captured stderr teardown ---------------------------
Traceback (most recent call last):
  File "/build/source/tests/lib/clients/03-publish-helper-qos0-v5.py", line 7, in <module>
    paho.mqtt.publish.single(
  File "/nix/store/sg4pgfbqcb5apkrsiq1npxvnwd4in57j-python3.12-paho-mqtt-2.1.0/lib/python3.12/site-packages/paho/mqtt/publish.py", line 305, in single
    multiple([msg], hostname, port, client_id, keepalive, will, auth, tls,
  File "/nix/store/sg4pgfbqcb5apkrsiq1npxvnwd4in57j-python3.12-paho-mqtt-2.1.0/lib/python3.12/site-packages/paho/mqtt/publish.py", line 228, in multiple
    client.loop_forever()
  File "/nix/store/sg4pgfbqcb5apkrsiq1npxvnwd4in57j-python3.12-paho-mqtt-2.1.0/lib/python3.12/site-packages/paho/mqtt/client.py", line 2297, in loop_forever
    rc = self._loop(timeout)
         ^^^^^^^^^^^^^^^^^^^
  File "/nix/store/sg4pgfbqcb5apkrsiq1npxvnwd4in57j-python3.12-paho-mqtt-2.1.0/lib/python3.12/site-packages/paho/mqtt/client.py", line 1703, in _loop
    rc = self.loop_write()
         ^^^^^^^^^^^^^^^^^
  File "/nix/store/sg4pgfbqcb5apkrsiq1npxvnwd4in57j-python3.12-paho-mqtt-2.1.0/lib/python3.12/site-packages/paho/mqtt/client.py", line 2121, in loop_write
    rc = self._packet_write()
         ^^^^^^^^^^^^^^^^^^^^
  File "/nix/store/sg4pgfbqcb5apkrsiq1npxvnwd4in57j-python3.12-paho-mqtt-2.1.0/lib/python3.12/site-packages/paho/mqtt/client.py", line 3230, in _packet_write
    self._sock_close()
  File "/nix/store/sg4pgfbqcb5apkrsiq1npxvnwd4in57j-python3.12-paho-mqtt-2.1.0/lib/python3.12/site-packages/paho/mqtt/client.py", line 1135, in _sock_close
    sock.close()
  File "/nix/store/rdq5zjrqdf9515q0kxps2dklhq7ybnwh-python3-3.12.10/lib/python3.12/socket.py", line 505, in close
    self._real_close()
  File "/nix/store/rdq5zjrqdf9515q0kxps2dklhq7ybnwh-python3-3.12.10/lib/python3.12/socket.py", line 499, in _real_close
    _ss.close(self)
KeyboardInterrupt
=========================== short test summary info ============================
XFAIL tests/lib/test_03_publish_fill_inflight.py::test_03_publish_fill_inflight
============= 162 passed, 1 xfailed, 1 error in 132.09s (0:02:12) ==============

Reproduction

  1. Run the test suite, using Python 3.12. Here done as part of the nixpkgs package.

The issue is not consistently reproducible.

Environment

  • Python version: 3.12
  • Library version: 2.1.0
  • Operating system (including version): Linux (NixOS 25.05 unstable)
  • MQTT server (name, version, configuration, hosting details): N/A

Metadata

Metadata

Assignees

No one assigned

    Labels

    Status: AvailableNo one has claimed responsibility for resolving this issue.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions