quamash
quamash copied to clipboard
RuntimeError: Failed to disconnect signal activated(int)
Im getting this randomly.... having trouble tying it down to a cause, but I figured I'd post here to see if anyone knew of any possible causes
Traceback (most recent call last):
File "/usr/lib/python3.4/asyncio/events.py", line 120, in _run
self._callback(*self._args)
File "/usr/local/lib/python3.4/dist-packages/quamash/__init__.py", line 449, in __notifier_cb_wrapper
notifier.activated.disconnect()
RuntimeError: Failed to disconnect signal activated(int).
So, I originally thought that this was causing some problems that I was having, but I have since fixed those problems and these tracebacks still appear... so they seem benign at this point
If you can find a way to definitively reproduce this, I'd still like to see the test case.
I hit this today and dug into it a little. The exception is coming out after firing the callback; for me the callback function is <bound method _SelectorSslTransport._read_ready of <_SelectorSslTransport fd=22 read=idle write=<idle, bufsize=0>>>
. It doesn't appear to be a problem for a non-SSL stream transport.
Here's some reproduce code:
import asyncio
import aiohttp
from PySide import QtGui
from quamash import QEventLoop
@asyncio.coroutine
def run(url):
s = aiohttp.ClientSession()
resp = yield from s.get(url)
print((yield from resp.text()))
resp.close()
s.close()
if __name__ == '__main__':
import logging
logging.basicConfig(level=logging.WARNING)
app = QtGui.QApplication([])
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
# no RuntimeError
loop.run_until_complete(run('http://www.bbc.co.uk'))
# RuntimeError gets raised for https
loop.run_until_complete(run('https://www.google.com'))
I found another issue with the same sort of signature; there they've added RuntimeError to the exception types they catch which matches the behavior for the TypeError which PyQT raises.
hrm. I'd strongly prefer steps to repro that don't depend on an external library, but this is better than before.
we're not catching any exceptions when trying to disconnect the signal; perhaps, we should just suppress TypeError
and RuntimeError
when disconnecting? maybe just log a warning?
I haven't done any work on quamash in long enough that I don't have a good devel environment for it. (thank fully Chris Gohlke builds PyQt wheels for windows now)
(the patch would be to find .disconnect(
in the source, and wrap it in the appropriate try...except: self._log.warn('...')
)
oh that's right pyqt5 is on pip
ok, python 3.4 with PySide test replicates, python 3.6 with PyQt5 it does not.
specifically the error is:
Traceback (most recent call last):
File ".\issue63.py", line 29, in <module>
loop.run_until_complete(run('https://www.google.com'))
File "C:\Users\gkmachine\Development\quamash\quamash\__init__.py", line 273, in run_until_complete
return future.result()
File "C:\Python34\lib\asyncio\futures.py", line 277, in result
raise self._exception
File "C:\Python34\lib\asyncio\tasks.py", line 234, in _step
result = coro.send(value)
File ".\issue63.py", line 12, in run
resp = yield from s.get(url)
File "C:\Users\gkmachine\Development\quamash\py34.pyside.env\lib\site-packages\aiohttp\client.py", line 530, in __iter__
resp = yield from self._coro
File "C:\Users\gkmachine\Development\quamash\py34.pyside.env\lib\site-packages\aiohttp\client.py", line 176, in _request
conn = yield from self._connector.connect(req)
File "C:\Users\gkmachine\Development\quamash\py34.pyside.env\lib\site-packages\aiohttp\connector.py", line 308, in connect
yield from self._create_connection(req)
File "C:\Users\gkmachine\Development\quamash\py34.pyside.env\lib\site-packages\aiohttp\connector.py", line 597, in _create_connection
transport, proto = yield from self._create_direct_connection(req)
File "C:\Users\gkmachine\Development\quamash\py34.pyside.env\lib\site-packages\aiohttp\connector.py", line 620, in _create_direct_connection
local_addr=self._local_addr)
File "C:\Python34\lib\asyncio\base_events.py", line 579, in create_connection
sock, protocol_factory, ssl, server_hostname)
File "C:\Python34\lib\asyncio\base_events.py", line 597, in _create_connection_transport
server_side=False, server_hostname=server_hostname)
File "C:\Python34\lib\asyncio\base_events.py", line 186, in _make_ssl_transport
raise NotImplementedError
NotImplementedError
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
QThread: Destroyed while thread is still running
ERROR:quamash.QEventLoop:Unclosed client session
client_session: <aiohttp.client.ClientSession object at 0x00000000051A6C18>
Here's the RuntimeError popping out without aiohttp in the mix:
import asyncio
from PySide import QtGui
from quamash import QEventLoop
@asyncio.coroutine
def run(loop, addr, port, ssl):
transport, protocol = yield from loop.create_connection(
asyncio.Protocol, host=addr, port=port, ssl=ssl)
print("SLEEP")
transport.write(b'GET / HTTP/1.0\r\n\r\n')
yield from asyncio.sleep(2, loop=loop)
print("WAKE")
transport.close()
if __name__ == '__main__':
import logging
logging.basicConfig(level=logging.WARNING)
app = QtGui.QApplication([])
loop = QEventLoop(app)
asyncio.set_event_loop(loop)
# no RuntimeError
loop.run_until_complete(run(loop, 'www.google.com', 80, ssl=False))
print('\n' * 5)
# RuntimeError gets raised for https
loop.run_until_complete(run(loop, 'www.google.com', 443, ssl=True))
well the point would be to put the tests in the unit test suite, but if they depend on external stuff then that's harder. the reduced test case would need to also connect to a local server?
FWIW the traceback I'm seeing points to Python 3.4 as the culprit not a PySide incompatibility. Is there anyway you can use a newer python? I know PySide is incompatible, but maybe you can use PySide2? Do you need to use PySide for licensing reasons or can you use PyQt? I'll try to repro with PyQt4 for Python3.4 and see if it still repros.
There are prebuilt PySide2 wheels here for Python 3.5; howerver, I wasn't able to get them to work.
pyqt4 + python3.4 displays a similar issue. pyqt4 + python3.5 doesn't show the issue. (I needed to install msvc++ redist 2015)
I got a different error from PySide2 after I installed msvc++ redist 2015, I'm gonna see if I can get it to work.
long story short, it looks like @croepha has a different issue than you do @dsalisbury
The one you're coming accross is a known problem with Python 3.4 and asyncio with SSL (that you should be able to google around for). Still don't know what @croepha's issue is.