orionis 0.483.0__py3-none-any.whl → 0.484.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- orionis/console/commands/scheduler_work.py +8 -0
- orionis/console/entities/__init__.py +0 -0
- orionis/console/entities/listeners.py +241 -0
- orionis/console/tasks/schedule.py +22 -2
- orionis/metadata/framework.py +1 -1
- {orionis-0.483.0.dist-info → orionis-0.484.0.dist-info}/METADATA +1 -1
- {orionis-0.483.0.dist-info → orionis-0.484.0.dist-info}/RECORD +11 -9
- {orionis-0.483.0.dist-info → orionis-0.484.0.dist-info}/WHEEL +0 -0
- {orionis-0.483.0.dist-info → orionis-0.484.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.483.0.dist-info → orionis-0.484.0.dist-info}/top_level.txt +0 -0
- {orionis-0.483.0.dist-info → orionis-0.484.0.dist-info}/zip-safe +0 -0
|
@@ -96,6 +96,9 @@ class ScheduleWorkCommand(BaseCommand):
|
|
|
96
96
|
if Scheduler is None:
|
|
97
97
|
raise CLIOrionisRuntimeError(f"Scheduler class not found in module {module_name}")
|
|
98
98
|
|
|
99
|
+
# Create an instance of the Scheduler class
|
|
100
|
+
Scheduler = Scheduler()
|
|
101
|
+
|
|
99
102
|
# Retrieve the 'tasks' method from the Scheduler class
|
|
100
103
|
task_method = getattr(Scheduler, "tasks", None)
|
|
101
104
|
if task_method is None:
|
|
@@ -107,6 +110,11 @@ class ScheduleWorkCommand(BaseCommand):
|
|
|
107
110
|
# Register scheduled tasks using the Scheduler's tasks method
|
|
108
111
|
task_method(schedule_serice)
|
|
109
112
|
|
|
113
|
+
# Register event listeners for the scheduler
|
|
114
|
+
onSchedulerStarted = getattr(Scheduler, "onSchedulerStarted", None)
|
|
115
|
+
if onSchedulerStarted:
|
|
116
|
+
schedule_serice.addListenerOnSchedulerStarted(onSchedulerStarted)
|
|
117
|
+
|
|
110
118
|
# Display a start message for the scheduler worker
|
|
111
119
|
console.line()
|
|
112
120
|
start_time = datetime.now().strftime('%Y-%m-%d %H:%M:%S')
|
|
File without changes
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
from dataclasses import dataclass
|
|
2
|
+
from datetime import datetime
|
|
3
|
+
from typing import Any
|
|
4
|
+
|
|
5
|
+
# ==============================================================
|
|
6
|
+
# Base Events
|
|
7
|
+
# ==============================================================
|
|
8
|
+
|
|
9
|
+
@dataclass
|
|
10
|
+
class SchedulerEventData:
|
|
11
|
+
"""
|
|
12
|
+
Base class for scheduler-related events.
|
|
13
|
+
|
|
14
|
+
Attributes
|
|
15
|
+
----------
|
|
16
|
+
code : int
|
|
17
|
+
The numeric event code indicating the event type.
|
|
18
|
+
"""
|
|
19
|
+
code: int
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
@dataclass
|
|
23
|
+
class JobEventData(SchedulerEventData):
|
|
24
|
+
"""
|
|
25
|
+
Base class for job-related events.
|
|
26
|
+
|
|
27
|
+
Attributes
|
|
28
|
+
----------
|
|
29
|
+
code : int
|
|
30
|
+
The numeric event code indicating the event type.
|
|
31
|
+
job_id : str
|
|
32
|
+
The identifier of the job.
|
|
33
|
+
jobstore : str
|
|
34
|
+
The name of the job store where the job is located.
|
|
35
|
+
"""
|
|
36
|
+
job_id: str
|
|
37
|
+
jobstore: str
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
# ==============================================================
|
|
41
|
+
# Scheduler Lifecycle Events
|
|
42
|
+
# ==============================================================
|
|
43
|
+
|
|
44
|
+
@dataclass
|
|
45
|
+
class SchedulerStarted(SchedulerEventData):
|
|
46
|
+
"""
|
|
47
|
+
Event triggered when the scheduler starts running.
|
|
48
|
+
"""
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
@dataclass
|
|
52
|
+
class SchedulerShutdown(SchedulerEventData):
|
|
53
|
+
"""
|
|
54
|
+
Event triggered when the scheduler shuts down.
|
|
55
|
+
"""
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
@dataclass
|
|
59
|
+
class SchedulerPaused(SchedulerEventData):
|
|
60
|
+
"""
|
|
61
|
+
Event triggered when the scheduler is paused.
|
|
62
|
+
"""
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
@dataclass
|
|
66
|
+
class SchedulerResumed(SchedulerEventData):
|
|
67
|
+
"""
|
|
68
|
+
Event triggered when the scheduler is resumed.
|
|
69
|
+
"""
|
|
70
|
+
|
|
71
|
+
|
|
72
|
+
# ==============================================================
|
|
73
|
+
# Executor and JobStore Events
|
|
74
|
+
# ==============================================================
|
|
75
|
+
|
|
76
|
+
@dataclass
|
|
77
|
+
class ExecutorAdded(SchedulerEventData):
|
|
78
|
+
"""
|
|
79
|
+
Event triggered when an executor is added.
|
|
80
|
+
|
|
81
|
+
Attributes
|
|
82
|
+
----------
|
|
83
|
+
alias : str
|
|
84
|
+
The alias of the added executor.
|
|
85
|
+
"""
|
|
86
|
+
alias: str
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@dataclass
|
|
90
|
+
class ExecutorRemoved(SchedulerEventData):
|
|
91
|
+
"""
|
|
92
|
+
Event triggered when an executor is removed.
|
|
93
|
+
|
|
94
|
+
Attributes
|
|
95
|
+
----------
|
|
96
|
+
alias : str
|
|
97
|
+
The alias of the removed executor.
|
|
98
|
+
"""
|
|
99
|
+
alias: str
|
|
100
|
+
|
|
101
|
+
|
|
102
|
+
@dataclass
|
|
103
|
+
class JobstoreAdded(SchedulerEventData):
|
|
104
|
+
"""
|
|
105
|
+
Event triggered when a job store is added.
|
|
106
|
+
|
|
107
|
+
Attributes
|
|
108
|
+
----------
|
|
109
|
+
alias : str
|
|
110
|
+
The alias of the added job store.
|
|
111
|
+
"""
|
|
112
|
+
alias: str
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
@dataclass
|
|
116
|
+
class JobstoreRemoved(SchedulerEventData):
|
|
117
|
+
"""
|
|
118
|
+
Event triggered when a job store is removed.
|
|
119
|
+
|
|
120
|
+
Attributes
|
|
121
|
+
----------
|
|
122
|
+
alias : str
|
|
123
|
+
The alias of the removed job store.
|
|
124
|
+
"""
|
|
125
|
+
alias: str
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
@dataclass
|
|
129
|
+
class AllJobsRemoved(SchedulerEventData):
|
|
130
|
+
"""
|
|
131
|
+
Event triggered when all jobs are removed from a job store.
|
|
132
|
+
|
|
133
|
+
Attributes
|
|
134
|
+
----------
|
|
135
|
+
jobstore : str
|
|
136
|
+
The alias of the job store from which jobs were removed.
|
|
137
|
+
"""
|
|
138
|
+
jobstore: str
|
|
139
|
+
|
|
140
|
+
|
|
141
|
+
# ==============================================================
|
|
142
|
+
# Job Management Events
|
|
143
|
+
# ==============================================================
|
|
144
|
+
|
|
145
|
+
@dataclass
|
|
146
|
+
class JobAdded(JobEventData):
|
|
147
|
+
"""
|
|
148
|
+
Event triggered when a job is added to a job store.
|
|
149
|
+
"""
|
|
150
|
+
|
|
151
|
+
|
|
152
|
+
@dataclass
|
|
153
|
+
class JobRemoved(JobEventData):
|
|
154
|
+
"""
|
|
155
|
+
Event triggered when a job is removed from a job store.
|
|
156
|
+
"""
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
@dataclass
|
|
160
|
+
class JobModified(JobEventData):
|
|
161
|
+
"""
|
|
162
|
+
Event triggered when a job is modified in a job store.
|
|
163
|
+
"""
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
@dataclass
|
|
167
|
+
class JobSubmitted(JobEventData):
|
|
168
|
+
"""
|
|
169
|
+
Event triggered when a job is submitted to an executor.
|
|
170
|
+
|
|
171
|
+
Attributes
|
|
172
|
+
----------
|
|
173
|
+
run_time : datetime
|
|
174
|
+
The datetime when the job was scheduled to run.
|
|
175
|
+
"""
|
|
176
|
+
run_time: datetime
|
|
177
|
+
|
|
178
|
+
|
|
179
|
+
@dataclass
|
|
180
|
+
class JobMaxInstances(JobEventData):
|
|
181
|
+
"""
|
|
182
|
+
Event triggered when a job exceeds its maximum allowed instances.
|
|
183
|
+
|
|
184
|
+
Attributes
|
|
185
|
+
----------
|
|
186
|
+
run_time : datetime
|
|
187
|
+
The datetime when the job was scheduled to run.
|
|
188
|
+
"""
|
|
189
|
+
run_time: datetime
|
|
190
|
+
|
|
191
|
+
|
|
192
|
+
# ==============================================================
|
|
193
|
+
# Job Execution Events
|
|
194
|
+
# ==============================================================
|
|
195
|
+
|
|
196
|
+
@dataclass
|
|
197
|
+
class JobExecuted(JobEventData):
|
|
198
|
+
"""
|
|
199
|
+
Event triggered when a job finishes successfully.
|
|
200
|
+
|
|
201
|
+
Attributes
|
|
202
|
+
----------
|
|
203
|
+
scheduled_run_time : datetime
|
|
204
|
+
The datetime when the job was scheduled to run.
|
|
205
|
+
retval : Any
|
|
206
|
+
The return value of the job function.
|
|
207
|
+
"""
|
|
208
|
+
scheduled_run_time: datetime
|
|
209
|
+
retval: Any
|
|
210
|
+
|
|
211
|
+
|
|
212
|
+
@dataclass
|
|
213
|
+
class JobError(JobEventData):
|
|
214
|
+
"""
|
|
215
|
+
Event triggered when a job raises an exception during execution.
|
|
216
|
+
|
|
217
|
+
Attributes
|
|
218
|
+
----------
|
|
219
|
+
scheduled_run_time : datetime
|
|
220
|
+
The datetime when the job was scheduled to run.
|
|
221
|
+
exception : Exception
|
|
222
|
+
The exception raised by the job.
|
|
223
|
+
traceback : str
|
|
224
|
+
The traceback of the exception.
|
|
225
|
+
"""
|
|
226
|
+
scheduled_run_time: datetime
|
|
227
|
+
exception: Exception
|
|
228
|
+
traceback: str
|
|
229
|
+
|
|
230
|
+
|
|
231
|
+
@dataclass
|
|
232
|
+
class JobMissed(JobEventData):
|
|
233
|
+
"""
|
|
234
|
+
Event triggered when a job run is missed due to scheduler constraints.
|
|
235
|
+
|
|
236
|
+
Attributes
|
|
237
|
+
----------
|
|
238
|
+
scheduled_run_time : datetime
|
|
239
|
+
The datetime when the job was originally scheduled to run.
|
|
240
|
+
"""
|
|
241
|
+
scheduled_run_time: datetime
|
|
@@ -2,7 +2,7 @@ import asyncio
|
|
|
2
2
|
import logging
|
|
3
3
|
from typing import Dict, List, Optional
|
|
4
4
|
import pytz
|
|
5
|
-
from apscheduler.events import EVENT_JOB_MISSED, EVENT_JOB_ERROR
|
|
5
|
+
from apscheduler.events import EVENT_JOB_MISSED, EVENT_JOB_ERROR, EVENT_ALL, EVENT_SCHEDULER_STARTED
|
|
6
6
|
from apscheduler.schedulers.asyncio import AsyncIOScheduler as APSAsyncIOScheduler
|
|
7
7
|
from orionis.console.contracts.reactor import IReactor
|
|
8
8
|
from orionis.console.contracts.schedule import ISchedule
|
|
@@ -80,7 +80,7 @@ class Scheduler(ISchedule):
|
|
|
80
80
|
self.__jobs: List[dict] = []
|
|
81
81
|
|
|
82
82
|
# Add a listener to the scheduler to capture job events such as missed jobs or errors.
|
|
83
|
-
self.__scheduler.add_listener(self.__listener,
|
|
83
|
+
self.__scheduler.add_listener(self.__listener, EVENT_ALL)
|
|
84
84
|
|
|
85
85
|
# Log the initialization of the Scheduler.
|
|
86
86
|
self.__logger.info("Orionis scheduler initialized.")
|
|
@@ -313,6 +313,26 @@ class Scheduler(ISchedule):
|
|
|
313
313
|
# Return the Event instance for further scheduling configuration
|
|
314
314
|
return self.__events[signature]
|
|
315
315
|
|
|
316
|
+
def addListenerOnSchedulerStarted(
|
|
317
|
+
self,
|
|
318
|
+
listener: callable
|
|
319
|
+
) -> None:
|
|
320
|
+
"""
|
|
321
|
+
Add a listener for the scheduler started event.
|
|
322
|
+
|
|
323
|
+
This method allows you to register a callback function that will be called
|
|
324
|
+
when the scheduler starts. The callback should accept a single argument, which
|
|
325
|
+
is the event object containing details about the scheduler start event.
|
|
326
|
+
|
|
327
|
+
Parameters
|
|
328
|
+
----------
|
|
329
|
+
listener : callable
|
|
330
|
+
A function that will be called when the scheduler starts.
|
|
331
|
+
It should accept one parameter, which is the event object.
|
|
332
|
+
"""
|
|
333
|
+
# Register the listener for the scheduler started event
|
|
334
|
+
self.__scheduler.add_listener(listener, EVENT_SCHEDULER_STARTED)
|
|
335
|
+
|
|
316
336
|
async def start(self) -> None:
|
|
317
337
|
"""
|
|
318
338
|
Start the AsyncIO scheduler instance and keep it running.
|
orionis/metadata/framework.py
CHANGED
|
@@ -15,7 +15,7 @@ orionis/console/commands/cache.py,sha256=8DsYoRzSBLn0P9qkGVItRbo0R6snWBDBg0_Xa7t
|
|
|
15
15
|
orionis/console/commands/help.py,sha256=ooPoenP08ArMAWiL89_oUGD9l1Faen2QjLTG90i4zCQ,3187
|
|
16
16
|
orionis/console/commands/publisher.py,sha256=FUg-EUzK7LLXsla10ZUZro8V0Z5S-KjmsaSdRHSSGbA,21381
|
|
17
17
|
orionis/console/commands/scheduler_list.py,sha256=SXaD1XJFV1bbyjlDuQhlHz2y1kW-VVCxQxuKJMtQRtA,5956
|
|
18
|
-
orionis/console/commands/scheduler_work.py,sha256=
|
|
18
|
+
orionis/console/commands/scheduler_work.py,sha256=eRd-IbburgcitIOpDo757F6lY_KQqO9oyKxszdQZsuU,6102
|
|
19
19
|
orionis/console/commands/test.py,sha256=_Tb-I9vabiqhqGeLfRbV5Y1LEVCdhZhBAwoEQZCzQuM,2435
|
|
20
20
|
orionis/console/commands/version.py,sha256=SUuNDJ40f2uq69OQUmPQXJKaa9Bm_iVRDPmBd7zc1Yc,3658
|
|
21
21
|
orionis/console/commands/workflow.py,sha256=NYOmjTSvm2o6AE4h9LSTZMFSYPQreNmEJtronyOxaYk,2451
|
|
@@ -34,6 +34,8 @@ orionis/console/dynamic/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG
|
|
|
34
34
|
orionis/console/dynamic/progress_bar.py,sha256=iK1kAf9vJIgk6BbdlGvlJkGc1m7Ck4euNqQpg5aarW8,2880
|
|
35
35
|
orionis/console/dynamic/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
36
36
|
orionis/console/dynamic/contracts/progress_bar.py,sha256=NYebL2h-vg2t2H6IhJjuC37gglRkpT-MW71wbJtpLNg,1784
|
|
37
|
+
orionis/console/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
|
+
orionis/console/entities/listeners.py,sha256=I5JbbnwKz-ZQhQgS2r1wqfUTwagg8Os6qzfEY8FzVzg,5345
|
|
37
39
|
orionis/console/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
38
40
|
orionis/console/enums/command.py,sha256=lCfVp2vnDojJN2gjdVxE_XU3mRjZZgOIxPfBVQYo9w4,1278
|
|
39
41
|
orionis/console/enums/event.py,sha256=XRV7N14N5HHt-c0HqYhrbKv4n2P7ZOCcBT_3OAQzenU,1929
|
|
@@ -53,7 +55,7 @@ orionis/console/output/enums/styles.py,sha256=6a4oQCOBOKMh2ARdeq5GlIskJ3wjiylYmh
|
|
|
53
55
|
orionis/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
54
56
|
orionis/console/tasks/event.py,sha256=NdOht_yXqKW0EIsIVrctIgOhQDWAR5fuMPEF05zTWtI,12029
|
|
55
57
|
orionis/console/tasks/exception_report.py,sha256=IN1PCQ08ZHs1sivUpzi2f9U9eW8ydZyb8GO6KiT56LY,3643
|
|
56
|
-
orionis/console/tasks/schedule.py,sha256=
|
|
58
|
+
orionis/console/tasks/schedule.py,sha256=3bELvGlYzsvPdwkUKrkMd_UxXT8Xp2bpOaMY1bRGwGY,20301
|
|
57
59
|
orionis/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
58
60
|
orionis/container/container.py,sha256=aF_b6lTUpG4YCo9yFJEzsntTdIzgMMXFW5LyWqAJVBQ,87987
|
|
59
61
|
orionis/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -200,7 +202,7 @@ orionis/foundation/providers/scheduler_provider.py,sha256=72SoixFog9IOE9Ve9Xcfw6
|
|
|
200
202
|
orionis/foundation/providers/testing_provider.py,sha256=SrJRpdvcblx9WvX7x9Y3zc7OQfiTf7la0HAJrm2ESlE,3725
|
|
201
203
|
orionis/foundation/providers/workers_provider.py,sha256=oa_2NIDH6UxZrtuGkkoo_zEoNIMGgJ46vg5CCgAm7wI,3926
|
|
202
204
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
203
|
-
orionis/metadata/framework.py,sha256=
|
|
205
|
+
orionis/metadata/framework.py,sha256=QHaUaU9LFBgHK8Xe_11Y_EDNM2zMoDL5Jq7FviFSCIg,4109
|
|
204
206
|
orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
|
|
205
207
|
orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
206
208
|
orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -372,7 +374,7 @@ orionis/test/validators/web_report.py,sha256=n9BfzOZz6aEiNTypXcwuWbFRG0OdHNSmCNu
|
|
|
372
374
|
orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnIfJYgc,1206
|
|
373
375
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
374
376
|
orionis/test/view/render.py,sha256=f-zNhtKSg9R5Njqujbg2l2amAs2-mRVESneLIkWOZjU,4082
|
|
375
|
-
orionis-0.
|
|
377
|
+
orionis-0.484.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
|
|
376
378
|
tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
377
379
|
tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
378
380
|
tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -519,8 +521,8 @@ tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
519
521
|
tests/testing/validators/test_testing_validators.py,sha256=WPo5GxTP6xE-Dw3X1vZoqOMpb6HhokjNSbgDsDRDvy4,16588
|
|
520
522
|
tests/testing/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
521
523
|
tests/testing/view/test_render.py,sha256=tnnMBwS0iKUIbogLvu-7Rii50G6Koddp3XT4wgdFEYM,1050
|
|
522
|
-
orionis-0.
|
|
523
|
-
orionis-0.
|
|
524
|
-
orionis-0.
|
|
525
|
-
orionis-0.
|
|
526
|
-
orionis-0.
|
|
524
|
+
orionis-0.484.0.dist-info/METADATA,sha256=JmsYHngCZy4ZwPJhAEqLVHng4Z58Mih5g6baeieDABQ,4801
|
|
525
|
+
orionis-0.484.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
526
|
+
orionis-0.484.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
|
527
|
+
orionis-0.484.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
528
|
+
orionis-0.484.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|