CabbageDevelopment/qasync

PyQt6 support?

Willy-JL opened this issue · 8 comments

I tried editing __init__.py mimicking PyQt5 , copy-pasting and changing to PyQt6 where relevant, but running the aiohttp example using PyQt6.QtWidgets ends up with this:

Traceback (most recent call last):
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/asyncio/selector_events.py", line 261, in _add_reader
    key = self._selector.get_key(fd)
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/selectors.py", line 193, in get_key
    raise KeyError("{!r} is not registered".format(fileobj)) from None
KeyError: '6 is not registered'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/willyjl/Coding/spicetify-easyinstall/test.py", line 95, in <module>
    qasync.run(main())
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/site-packages/qasync/__init__.py", line 797, in run
    return asyncio.run(*args, **kwargs)
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/asyncio/runners.py", line 39, in run
    loop = events.new_event_loop()
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/asyncio/events.py", line 761, in new_event_loop
    return get_event_loop_policy().new_event_loop()
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/site-packages/qasync/__init__.py", line 775, in new_event_loop
    return QEventLoop(QApplication(sys.argv))
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/site-packages/qasync/__init__.py", line 335, in __init__
    super().__init__()
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/site-packages/qasync/_unix.py", line 198, in __init__
    asyncio.SelectorEventLoop.__init__(self, selector)
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/asyncio/unix_events.py", line 54, in __init__
    super().__init__(selector)
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/asyncio/selector_events.py", line 61, in __init__
    self._make_self_pipe()
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/asyncio/selector_events.py", line 112, in _make_self_pipe
    self._add_reader(self._ssock.fileno(), self._read_from_self)
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/asyncio/selector_events.py", line 263, in _add_reader
    self._selector.register(fd, selectors.EVENT_READ,
  File "/home/willyjl/.pyenv/versions/3.9.6/lib/python3.9/site-packages/qasync/_unix.py", line 112, in register
    notifier = QtCore.QSocketNotifier(key.fd, QtCore.QSocketNotifier.Read)
AttributeError: type object 'QSocketNotifier' has no attribute 'Read'
sys:1: RuntimeWarning: coroutine 'main' was never awaited

Is PyQt6 support planned? Am I missing something?

PyQt6 isn't fully supported yet, sorry. Some changes were made for PyQt6 but it's incomplete. I can't really say when/if I'll have time to finish it.

No worries, and thanks for even making this in the first place :D

@Willy-JL I have created a PR #53 that supports PyQt6, hopefully it will be accepted soon.

Until my PR is accepted you could install my version through the command:

pip install git+https://github.com/eyllanesc/qasync.git@PyQt6

@eyllanesc
I have installed your version but I have this error with from __feature__ import snake_case.

AttributeError: '_SimpleTimer' object has no attribute 'startTimer'
ERROR:qasync._QEventLoop:Task was destroyed but it is pending!

@sharpordie qasync does not support PySide6's snake_case feature, if you wish then you should create another issue pointing out your requirement more clearly.

@TheGreatCabbage I think this issue should be closed.

Ah, just saw the PR was merged. Thanks again mate!

Should README.md be updated to reflect this change? It specifically states "PyQt5 or PySide2".