CabbageDevelopment / qasync

Python library for using asyncio in Qt-based applications.
BSD 2-Clause "Simplified" License
321 stars 45 forks source link

open_connection() fails to report connection refused error on OpenBSD #118

Open sbourdeauducq opened 5 months ago

sbourdeauducq commented 5 months ago

Repro:

import asyncio
import logging

from PyQt5 import QtWidgets
import qasync

logging.basicConfig(level=logging.DEBUG)

app = QtWidgets.QApplication(["test"])
loop = qasync.QEventLoop(app)
asyncio.set_event_loop(loop)
loop.set_debug(True)
loop.run_until_complete(asyncio.open_connection("127.0.0.1", 3251))  # with the port not open

Output:

DEBUG:asyncio:Using selector: _Selector
DEBUG:qasync._QEventLoop:Running <coroutine object open_connection at 0x6dd6e8f69d0> until complete
DEBUG:qasync._QEventLoop:Registering callback <TaskStepMethWrapper object at 0x6dd6e97ddb0> to be invoked with arguments () after 0 second(s)
DEBUG:qasync._SimpleTimer:Registering timer id 1
DEBUG:qasync._QEventLoop:Starting Qt event loop
DEBUG:qasync._SimpleTimer:Timer event on id 1
DEBUG:qasync._SimpleTimer:Calling handle <Handle <TaskStepMethWrapper object at 0x6dd6e97ddb0>() created at /home/sb/qasync/qasync/__init__.py:472>
DEBUG:qasync._QEventLoop:Adding writer callback for file descriptor 24

Runs until killed and uses 100% CPU.

Expected behavior would be something like:

  File "/usr/local/lib/python3.10/asyncio/selector_events.py", line 541, in _sock_connect_cb
    raise OSError(err, f'Connect call failed {address}')
ConnectionRefusedError: [Errno 61] Connect call failed ('127.0.0.1', 3251)

(as occurs with the default asyncio event loop)