Skip to content

Commit e610e8b

Browse files
committed
fix(worker): use new event loop for Python 3.14+
Switches to asyncio.new_event_loop() for Python 3.14 and above, as asyncio.get_event_loop() is deprecated. Maintains compatibility with older Python versions by conditionally selecting the event loop method. Incorporated fix from python-arq#509 by https://github.com/a3lme
1 parent fda407c commit e610e8b

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

arq/worker.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import inspect
44
import logging
55
import signal
6+
import sys
67
from collections.abc import Sequence
78
from dataclasses import dataclass
89
from datetime import datetime, timedelta, timezone
@@ -267,7 +268,7 @@ def __init__(
267268
# self.job_tasks holds references the actual jobs running
268269
self.job_tasks: dict[str, asyncio.Task[Any]] = {}
269270
self.main_task: Optional[asyncio.Task[None]] = None
270-
self.loop = asyncio.get_event_loop()
271+
self.loop = asyncio.get_event_loop() if sys.version_info < (3, 14) else asyncio.new_event_loop()
271272
self.ctx = ctx or {}
272273
max_timeout = max(f.timeout_s or self.job_timeout_s for f in self.functions.values())
273274
self.in_progress_timeout_s = (max_timeout or 0) + 10

0 commit comments

Comments
 (0)