Skip to content

Async function not work outside of class #177

Description

@jekoie

I had write a simple test demo, the qt original method work fine, but qasync not working?

Code Sample

from qasync import QEventLoop as EventLoop, asyncSlot
import asyncio
from qtpy.QtCore import *
from qtpy.QtWidgets import *


async def main(app:QApplication, win:QWidget):
    ev = asyncio.Event()
    app.aboutToQuit.connect(ev.set)
    win.show()
    await ev.wait()


app = QApplication()
win =  QPushButton("test")

@asyncSlot()
async def on_click(*args):
    print("xx1")

win.clicked.connect(on_click)

def on_click1():
    print("good")

win.clicked.connect(on_click1)

asyncio.run(main(app, win), loop_factory=EventLoop)

Log Message

(d2l) D:\test\test1>C:/Users/Jett.Chen/.conda/envs/d2l/python.exe d:/test/test1/t1.py
Traceback (most recent call last):
  File "C:\Users\Jett.Chen\.conda\envs\d2l\Lib\site-packages\qasync\__init__.py", line 842, in wrapper
    raise TypeError(
TypeError: asyncSlot was not callable from Signal. Potential signature mismatch.
good
Traceback (most recent call last):
  File "C:\Users\Jett.Chen\.conda\envs\d2l\Lib\site-packages\qasync\__init__.py", line 842, in wrapper
    raise TypeError(
TypeError: asyncSlot was not callable from Signal. Potential signature mismatch.
good

(d2l) D:\test\test1>pip show PySide6
Name: PySide6
Version: 6.10.2
Summary: Python bindings for the Qt cross-platform application and UI framework
Home-page: https://pyside.org
Author: 
Author-email: Qt for Python Team <pyside@qt-project.org>
License: LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
Location: C:\Users\Jett.Chen\.conda\envs\d2l\Lib\site-packages
Requires: PySide6_Addons, PySide6_Essentials, shiboken6
Required-by: 

(d2l) D:\test\test1>pip show qasync
Name: qasync
Version: 0.28.0
Summary: Python library for using asyncio in Qt-based applications
Home-page: https://github.com/CabbageDevelopment/qasync
Author: Arve Knudsen, Gerard Marull-Paretas, Mark Harviston, Alex March, Sam McCormack
Author-email: Arve Knudsen <arve.knudsen@gmail.com>, Gerard Marull-Paretas <gerard@teslabs.com>, Mark Harviston <mark.harviston@gmail.com>, Alex March <alexmarch@fastmail.com>
License-Expression: BSD-2-Clause
Location: C:\Users\Jett.Chen\.conda\envs\d2l\Lib\site-packages
Requires: 
Required-by: 

(d2l) D:\test\test1>

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions