harvimt / quamash

Implementation of the PEP 3156 event-loop (asyncio) api using the Qt Event-Loop
BSD 2-Clause "Simplified" License
264 stars 46 forks source link

Windows Errors #38

Open harvimt opened 9 years ago

harvimt commented 9 years ago

The PyQt4 and PyQt5 tests on appveyor are passing, but I get this:

Exception ignored in: <bound method _ProactorSocketTransport.__del__ of <_ProactorSocketTransport closing fd=-1 read=<_OverlappedFuture cancelled>>>
Traceback (most recent call last):
  File "C:\Python34\lib\asyncio\proactor_events.py", line 86, in __del__
    self.close()
  File "C:\Python34\lib\asyncio\proactor_events.py", line 74, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\projects\quamash\quamash\__init__.py", line 365, in call_soon
    return self.call_later(0, callback, *args)
  File "C:\projects\quamash\quamash\__init__.py", line 345, in call_later
    return self._add_callback(asyncio.Handle(callback, args, self), delay)
  File "C:\projects\quamash\quamash\__init__.py", line 359, in _add_callback
    self.__timers.append(timer)
AttributeError: 'NoneType' object has no attribute 'append'
Exception ignored in: <bound method _ProactorSocketTransport.__del__ of <_ProactorSocketTransport closing fd=-1 read=<_OverlappedFuture cancelled>>>
Traceback (most recent call last):
  File "C:\Python34\lib\asyncio\proactor_events.py", line 86, in __del__
    self.close()
  File "C:\Python34\lib\asyncio\proactor_events.py", line 74, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\projects\quamash\quamash\__init__.py", line 365, in call_soon
    return self.call_later(0, callback, *args)
  File "C:\projects\quamash\quamash\__init__.py", line 345, in call_later
    return self._add_callback(asyncio.Handle(callback, args, self), delay)
  File "C:\projects\quamash\quamash\__init__.py", line 359, in _add_callback
    self.__timers.append(timer)
AttributeError: 'NoneType' object has no attribute 'append'
Exception ignored in: <bound method _ProactorSocketTransport.__del__ of <_ProactorSocketTransport closing fd=-1 read=<_OverlappedFuture cancelled>>>
Traceback (most recent call last):
  File "C:\Python34\lib\asyncio\proactor_events.py", line 86, in __del__
    self.close()
  File "C:\Python34\lib\asyncio\proactor_events.py", line 74, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\projects\quamash\quamash\__init__.py", line 365, in call_soon
    return self.call_later(0, callback, *args)
  File "C:\projects\quamash\quamash\__init__.py", line 345, in call_later
    return self._add_callback(asyncio.Handle(callback, args, self), delay)
  File "C:\projects\quamash\quamash\__init__.py", line 359, in _add_callback
    self.__timers.append(timer)
AttributeError: 'NoneType' object has no attribute 'append'

may be related to #34

PySide tests give off a similar error, in addition to:

QObject::startTimer: QTimer can only be used with threads started with QThread
QObject::startTimer: QTimer can only be used with threads started with QThread
QObject::startTimer: QTimer can only be used with threads started with QThread

but fail, however, the PySide tests have been failing for awhile for no reason on windows (like the tests all pass, but the exit code of py.test is non-zero)

Insoleet commented 9 years ago

I also have these errors, in my app and in my tests, when closing the event loop :

ERROR:quamash.QEventLoop:Cancelling an overlapped future failed
future: <_OverlappedFuture pending overlapped=<pending, 0x42bde50> cb=[BaseProactorEventLoop._loop_self_reading()]>
Traceback (most recent call last):
  File "D:\Anaconda3_64\lib\asyncio\windows_events.py", line 62, in _cancel_overlapped
    self._ov.cancel()
OSError: [WinError 6] The handle is invalid

Debugging with pycharm, here is what I found. The line https://github.com/python/asyncio/blob/master/asyncio/proactor_events.py#L455 is called the the future named "_self_reading_future" is canceled and set to None. It's descriptor address is for example "133875888".

But then, in https://github.com/python/asyncio/blob/7baef9de28bd0a8e5bb14ad962059dced9f23bb3/asyncio/windows_events.py#L718, there remains for some reason a future calling as a callback "QEventLoop._loop_self_reading" in the cache, and is pending. This future is then canceled. It's descriptor is different from the previous one ( adress : 133875744 ) but an error is present on this one : 997. If I follow microsoft doc ( https://msdn.microsoft.com/en-us/library/windows/desktop/ms681388%28v=vs.85%29.aspx ), 997 means : ERROR_IO_PENDING, Overlapped I/O operation is in progress.

Insoleet commented 9 years ago

This pull request was doing a regression. The logs in this issue are not present, but with my patch they come back.