summaryrefslogtreecommitdiff
path: root/src/apscheduler/_context.py
diff options
context:
space:
mode:
authorAlex Grönholm <alex.gronholm@nextday.fi>2022-07-30 22:34:16 +0300
committerAlex Grönholm <alex.gronholm@nextday.fi>2022-07-30 23:52:08 +0300
commitb1b45ba4e987b4efa91e4b7d0d744f50dccf5637 (patch)
tree11bc2995515e9d247dcdc28720a2a9315382057f /src/apscheduler/_context.py
parent0bc26e22b458ec0f013c467ef6206130257d03be (diff)
downloadapscheduler-b1b45ba4e987b4efa91e4b7d0d744f50dccf5637.tar.gz
Made the apscheduler.context module private and re-exported its code
Diffstat (limited to 'src/apscheduler/_context.py')
-rw-r--r--src/apscheduler/_context.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/src/apscheduler/_context.py b/src/apscheduler/_context.py
new file mode 100644
index 0000000..42ccf87
--- /dev/null
+++ b/src/apscheduler/_context.py
@@ -0,0 +1,22 @@
+from __future__ import annotations
+
+from contextvars import ContextVar
+from typing import TYPE_CHECKING
+
+if TYPE_CHECKING:
+ from .schedulers.async_ import AsyncScheduler
+ from .schedulers.sync import Scheduler
+ from .structures import JobInfo
+ from .workers.async_ import AsyncWorker
+ from .workers.sync import Worker
+
+#: The currently running (local) scheduler
+current_scheduler: ContextVar[Scheduler | AsyncScheduler | None] = ContextVar(
+ "current_scheduler", default=None
+)
+#: The worker running the current job
+current_worker: ContextVar[Worker | AsyncWorker | None] = ContextVar(
+ "current_worker", default=None
+)
+#: Metadata about the current job
+job_info: ContextVar[JobInfo] = ContextVar("job_info")