New to async programming I was trying to get the data of song simultaneously and update the thumbnail image of that song in a pyqt5 window
The code that I wrote is :
async def search(self,query):
self.query=query
try:
await asyncio.gather(
player.fetch(self.query),
dh.get(self.query))
except Exception as e:
print(e)
def search_bar_return_pressed(self):
search_text = self.search_bar.text()
loop = asyncio.get_event_loop()
result = loop.run_until_complete(self.search(search_text))
image_data=io.BytesIO(result[0])
image = QImage()
image.loadFromData(image_data)
pixmap = QPixmap.fromImage(image)
self.thumbnail_search.setScene(QtGui.QGraphicsScene())
self.thumbnail_search.scene().addPixmap(pixmap)
The output I got :
DeprecationWarning: There is no current event loop
loop = asyncio.get_event_loop()
unable to open database file
Traceback (most recent call last):
File "d:python bakchodisoundifymain.py", line 217, in search_bar_return_pressed
image_data=io.BytesIO(result[0])
~~~~~~^^^
TypeError: 'NoneType' object is not subscriptable
What thing wrong have I done