I am developing a plugin based on a library that uses the python library asyncio.
My plugin uses already the treading mechanism as explained in https://github.com/domoticz/domoticz/bl ... hreaded.py.
From the asyncio documentation, it is clear that this can be used even in a thread by just using the asyncio.run() statement.
However when doing this, I always got an error "there is no current event loop in thread", while for the asyncio.run() there is no need to initialize a loop.
Any idea?
My thread-function looks like (concept)
Code: Select all
def handleTasks(self):
Domoticz.Debug('Entering tasks handler')
try:
while True:
task = self.tasksQueue.get(block=True)
if task is None:
Domoticz.Debug('Exiting task handler')
self.tasksQueue.task_done()
break
Domoticz.Debug('Handling task: {}.'.format(task['Action']))
if task['Action'] == 'Login':
try:
asyncio.run(my_routine_using_asyncio())
except Exception as err:
Domoticz.Debug('Login error: {}'.format(err))