From 631c78e7161cfe8457bf1121eb355e3a3d19c35d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alex=20Gr=C3=B6nholm?= Date: Fri, 23 Sep 2022 00:28:29 +0300 Subject: Fixed _temporary_failure_exceptions in MongoDB and SQLA datastores --- src/apscheduler/_retry.py | 2 +- src/apscheduler/datastores/mongodb.py | 4 +++- src/apscheduler/datastores/sqlalchemy.py | 8 ++++++++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/src/apscheduler/_retry.py b/src/apscheduler/_retry.py index 19cf51b..f05931f 100644 --- a/src/apscheduler/_retry.py +++ b/src/apscheduler/_retry.py @@ -44,7 +44,7 @@ class RetryMixin: retry_settings: RetrySettings = attrs.field(default=RetrySettings()) @property - def _temporary_failure_exceptions(self) -> tuple[type[Exception]]: + def _temporary_failure_exceptions(self) -> tuple[type[Exception], ...]: """ Tuple of exception classes which indicate that the operation should be retried. diff --git a/src/apscheduler/datastores/mongodb.py b/src/apscheduler/datastores/mongodb.py index 06e27fd..4d47878 100644 --- a/src/apscheduler/datastores/mongodb.py +++ b/src/apscheduler/datastores/mongodb.py @@ -76,7 +76,9 @@ class MongoDBDataStore(BaseExternalDataStore): ] _job_attrs: ClassVar[list[str]] = [field.name for field in attrs.fields(Job)] - _temporary_failure_exceptions = (ConnectionFailure,) + @property + def _temporary_failure_exceptions(self) -> tuple[type[Exception], ...]: + return (ConnectionFailure,) def __attrs_post_init__(self) -> None: type_registry = TypeRegistry( diff --git a/src/apscheduler/datastores/sqlalchemy.py b/src/apscheduler/datastores/sqlalchemy.py index 2322205..3fcae32 100644 --- a/src/apscheduler/datastores/sqlalchemy.py +++ b/src/apscheduler/datastores/sqlalchemy.py @@ -206,6 +206,14 @@ class SQLAlchemyDataStore(BaseExternalDataStore): else: return await to_thread.run_sync(conn.execute, statement, parameters) + @property + def _temporary_failure_exceptions(self) -> tuple[type[Exception], ...]: + # SQlite does not use the network, so it doesn't have "temporary" failures + if self.engine.dialect == "sqlite": + return () + + return InterfaceError, OSError + def get_table_definitions(self) -> MetaData: if self.engine.dialect.name == "postgresql": from sqlalchemy.dialects import postgresql -- cgit v1.2.1