Fix imports for micropython
This commit is contained in:
+7
-3
@@ -1,6 +1,10 @@
|
|||||||
import time
|
import time
|
||||||
import asyncio
|
try:
|
||||||
import inspect
|
import asyncio
|
||||||
|
import inspect
|
||||||
|
ASYNCIO = True
|
||||||
|
except ImportError:
|
||||||
|
ASYNCIO = False
|
||||||
|
|
||||||
class AlertManager:
|
class AlertManager:
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@@ -12,7 +16,7 @@ class AlertManager:
|
|||||||
|
|
||||||
def call_on_alert_callback(self, alert):
|
def call_on_alert_callback(self, alert):
|
||||||
if self.on_alert_callback:
|
if self.on_alert_callback:
|
||||||
if inspect.iscoroutinefunction(self.on_alert_callback):
|
if ASYNCIO and inspect.iscoroutinefunction(self.on_alert_callback):
|
||||||
# Schedule coroutine on the running loop without blocking
|
# Schedule coroutine on the running loop without blocking
|
||||||
try:
|
try:
|
||||||
loop = asyncio.get_running_loop()
|
loop = asyncio.get_running_loop()
|
||||||
|
|||||||
Reference in New Issue
Block a user