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

quamash along with asyncio doesn't seem to catch exceptions correctly #91

Open
argoneuscze opened this issue Apr 10, 2018 · 2 comments
Open

Comments

@argoneuscze
Copy link

argoneuscze commented Apr 10, 2018

Hello,

I have this minimal code to reproduce the problem:

import asyncio
import sys

from PyQt5.QtWidgets import QApplication
from quamash import QEventLoop


def problem():
    app = QApplication(sys.argv)
    loop = QEventLoop(app)
    asyncio.set_event_loop(loop)

    loop.run_until_complete(conn())


async def conn():
    try:
        reader, writer = await asyncio.open_connection('127.0.0.1', 7777)
    except ConnectionRefusedError:
        print('exception?')

problem()

When the target server is down, it should catch the exception and print the text. But what actually happens is this error:

Event callback failed
Traceback (most recent call last):
  File "D:\Documents\Programming\venv\lib\site-packages\quamash\_windows.py", line 42, in _process_events
    value = callback(transferred, key, ov)
  File "D:\Programy\Python\Python36\lib\asyncio\windows_events.py", line 514, in finish_connect
    ov.getresult()
ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection

I'm at a loss as to what I could do to fix this... when I tried using the default asyncio event loop instead, it worked just fine.

Thanks a lot for any help.

@altendky
Copy link

I'll note that in Linux I got the desired exception? printed out.

 ⚙  ~/misc/expe/argoneus   masterpython3.6 -m venv venv
~/misc/expe/argoneus   mastervenv/bin/pip install quamash pyqt5
Collecting quamash
  Downloading Quamash-0.6.0-py3-none-any.whl
Collecting pyqt5
  Using cached PyQt5-5.10.1-5.10.1-cp35.cp36.cp37.cp38-abi3-manylinux1_x86_64.whl
Collecting sip<4.20,>=4.19.4 (from pyqt5)
  Using cached sip-4.19.8-cp36-cp36m-manylinux1_x86_64.whl
Installing collected packages: quamash, sip, pyqt5
Successfully installed pyqt5-5.10.1 quamash-0.6.0 sip-4.19.8
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.
 ~/misc/expe/argoneus   mastervenv/bin/python t.py
exception?

I get the same result as @argoneuscze in Windows.

PS C:\epc\t\812\testy> py -3.6 -m venv venv
PS C:\epc\t\812\testy> venv\scripts\pip install quamash pyqt5
Collecting quamash
  Downloading Quamash-0.6.0-py3-none-any.whl
Collecting pyqt5
  Using cached PyQt5-5.10.1-5.10.1-cp35.cp36.cp37.cp38-none-win_amd64.whl
Collecting sip<4.20,>=4.19.4 (from pyqt5)
  Using cached sip-4.19.8-cp36-none-win_amd64.whl
Installing collected packages: quamash, sip, pyqt5
Successfully installed pyqt5-5.10.1 quamash-0.6.0 sip-4.19.8
You are using pip version 9.0.1, however version 9.0.3 is available.
You should consider upgrading via the 'python -m pip install --upgrade pip' command.
PS C:\epc\t\812\testy> venv\scripts\python t.py
Event callback failed
Traceback (most recent call last):
  File "C:\epc\t\812\testy\venv\lib\site-packages\quamash\_windows.py", line 42, in _process_events
    value = callback(transferred, key, ov)
  File "C:\Program Files\Python36\lib\asyncio\windows_events.py", line 514, in finish_connect
    ov.getresult()
ConnectionRefusedError: [WinError 1225] The remote computer refused the network connection

Note that the program hung and did not return to the prompt.

@Insoleet
Copy link
Contributor

Insoleet commented Aug 4, 2018

On Windows, Quamash uses IOCPProactorLoop. See issue : #45

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

3 participants