How to run async in different thread?
Unsolved
Qt for Python
-
Hi all,
this might be a dumb question, please bear with me, i started coding in python just a short time ago.
I had my code running on a different QThread and it worked great. Now I had to change the API i use inside the function, and this new function requires me to await my function. So i am basically calling an awaited function.
But when I execute it I get an error:
RuntimeWarning: coroutine 'cTelegram.sendImage' was never awaited
self.exec_()I call my task like this:
self.telegramThread = QThread() self.telegramWorker = TelethonClass.cTelegram() self.telegramWorker.moveToThread(self.telegramThread) self.tgSig.tgSignal.connect(self.telegramWorker.sendImage) self.telegramThread.start()
and my called code is this:
class cTelegram(QObject): async def sendImage(self, im0, depot, score, classname): .... some irrelevant suff here... await bot.send_file(-11111111113, image_stream)
What am I doing wrong?
Thank you
-
Hi,
I think the issue here is that you are mixing two different aspects. The async/await parts require an event loop to run but you don't create one and that loop is not the one from Qt either.