Skip to content

exceptions not set on pending futures #109

@hartytp

Description

@hartytp

The following code snippet should tries to connect to a server that doesn't exist

host = "127.0.0.1"
port = 5000

try:
    print("connecting...")   
    loop = asyncio.get_event_loop()
    loop.run_until_complete(asyncio.open_connection(host, port))
except Exception as e:
    print("exception" , e)
print("done")

Expected behaviour is that a ConnectionRefusedError is raised. Without Quamash, that is what happens. With quamash, run_until_complete never finishes and the following warning is printed

WARNING<7>:quamash._QEventLoop:Event callback failed
Traceback (most recent call last):
  File "c:\scratch\quamash\quamash\_windows.py", line 42, in _process_events
    value = callback(transferred, key, ov)
  File "C:\Users\localadmin\Anaconda3\envs\artiq-env\lib\asyncio\windows_events.py", line 509, in finish_connect
    ov.getresult()
ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection

It looks like the future gets stuck in the PENDING state. I believe this is related to e5fc6b1

Changing this to

except OSError as e:
    self._logger.warning('Event callback failed', exc_info=sys.exc_info())
    if not f.done():
        f.set_exception(e)

seems to resolve the issue. Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions