summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2022-09-04 02:56:11 +0300
committerAlex Grönholm <alex.gronholm@nextday.fi>2022-09-04 02:56:11 +0300
commit2a0eac6fb42391cd5f356a94fa77b901d4b6bcd8 (patch)
tree06b8b53f865e43bb9af457ef1bfdce05db178d4b
parent5f0627be932d561c92bedc684ab1b8c5646520d4 (diff)
downloadapscheduler-2a0eac6fb42391cd5f356a94fa77b901d4b6bcd8.tar.gz
Fixed asyncpg/redis start() while cancelled resulting in an inconsistent cancel scope stack
-rw-r--r--src/apscheduler/eventbrokers/async_redis.py2
-rw-r--r--src/apscheduler/eventbrokers/asyncpg.py12
2 files changed, 9 insertions, 5 deletions
diff --git a/src/apscheduler/eventbrokers/async_redis.py b/src/apscheduler/eventbrokers/async_redis.py
index c2a5711..5e71621 100644
--- a/src/apscheduler/eventbrokers/async_redis.py
+++ b/src/apscheduler/eventbrokers/async_redis.py
@@ -80,7 +80,7 @@ class AsyncRedisEventBroker(LocalAsyncEventBroker, DistributedEventBrokerMixin):
pubsub = self.client.pubsub()
try:
await pubsub.subscribe(self.channel)
- except Exception:
+ except BaseException:
await self.stop(force=True)
raise
diff --git a/src/apscheduler/eventbrokers/asyncpg.py b/src/apscheduler/eventbrokers/asyncpg.py
index 4ee2339..27b1bed 100644
--- a/src/apscheduler/eventbrokers/asyncpg.py
+++ b/src/apscheduler/eventbrokers/asyncpg.py
@@ -130,10 +130,14 @@ class AsyncpgEventBroker(LocalAsyncEventBroker, DistributedEventBrokerMixin):
async def start(self) -> None:
await super().start()
- self._send = cast(
- MemoryObjectSendStream[str],
- await self._task_group.start(self._listen_notifications),
- )
+ try:
+ self._send = cast(
+ MemoryObjectSendStream[str],
+ await self._task_group.start(self._listen_notifications),
+ )
+ except BaseException:
+ await super().stop(force=True)
+ raise
async def stop(self, *, force: bool = False) -> None:
self._send.close()