Change for cancelled error on older Python versions
@@ -18,14 +18,13 @@ from tomodachi.helpers.execution_context import clear_execution_context, clear_s
from tomodachi.helpers.safe_modules import SAFE_MODULES
from tomodachi.importer import ServiceImporter
+CancelledError = asyncio.CancelledError
try:
asyncioexceptions = getattr(asyncio, "exceptions")
if asyncioexceptions:
- CancelledError = asyncioexceptions.CancelledError
-except Exception:
-
- class CancelledError(Exception): # type: ignore
- pass
+ _CancelledError = asyncioexceptions.CancelledError
+except (Exception, ModuleNotFoundError, ImportError):
+ _CancelledError = asyncio.CancelledError
class ServiceLauncher(object):
@@ -287,5 +286,5 @@ class ServiceLauncher(object):
if not watcher_future.done(): # pragma: no cover
try:
loop.run_until_complete(watcher_future)
- except (Exception, CancelledError):
+ except (Exception, CancelledError, _CancelledError):
pass
