orionis 0.517.0__py3-none-any.whl → 0.519.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/base/scheduler.py +109 -34
- orionis/console/contracts/scheduler.py +104 -55
- orionis/console/tasks/schedule.py +38 -28
- orionis/metadata/framework.py +1 -1
- {orionis-0.517.0.dist-info → orionis-0.519.0.dist-info}/METADATA +1 -1
- {orionis-0.517.0.dist-info → orionis-0.519.0.dist-info}/RECORD +10 -10
- {orionis-0.517.0.dist-info → orionis-0.519.0.dist-info}/WHEEL +0 -0
- {orionis-0.517.0.dist-info → orionis-0.519.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.517.0.dist-info → orionis-0.519.0.dist-info}/top_level.txt +0 -0
- {orionis-0.517.0.dist-info → orionis-0.519.0.dist-info}/zip-safe +0 -0
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
from datetime import datetime
|
|
2
2
|
from orionis.console.contracts.scheduler import IBaseScheduler
|
|
3
3
|
from orionis.console.contracts.schedule import ISchedule
|
|
4
|
+
from orionis.console.entities.job_error import JobError
|
|
5
|
+
from orionis.console.entities.scheduler_paused import SchedulerPaused
|
|
6
|
+
from orionis.console.entities.scheduler_resumed import SchedulerResumed
|
|
7
|
+
from orionis.console.entities.scheduler_shutdown import SchedulerShutdown
|
|
8
|
+
from orionis.console.entities.scheduler_started import SchedulerStarted
|
|
4
9
|
|
|
5
10
|
class BaseScheduler(IBaseScheduler):
|
|
6
11
|
|
|
@@ -17,6 +22,9 @@ class BaseScheduler(IBaseScheduler):
|
|
|
17
22
|
"""
|
|
18
23
|
Defines and registers scheduled tasks for the application.
|
|
19
24
|
|
|
25
|
+
This method is responsible for setting up the tasks that the scheduler will execute.
|
|
26
|
+
It uses the provided `schedule` object to define the properties and behavior of each task.
|
|
27
|
+
|
|
20
28
|
Parameters
|
|
21
29
|
----------
|
|
22
30
|
schedule : ISchedule
|
|
@@ -25,96 +33,163 @@ class BaseScheduler(IBaseScheduler):
|
|
|
25
33
|
Returns
|
|
26
34
|
-------
|
|
27
35
|
None
|
|
28
|
-
This method does not return any value. It is
|
|
29
|
-
|
|
36
|
+
This method does not return any value. It is used solely for task registration.
|
|
37
|
+
|
|
38
|
+
Notes
|
|
39
|
+
-----
|
|
40
|
+
Subclasses must override this method to implement their specific task scheduling logic.
|
|
41
|
+
The method should define the tasks, their execution intervals, and any additional
|
|
42
|
+
properties or constraints required for the tasks.
|
|
30
43
|
"""
|
|
31
|
-
# Placeholder for task registration logic
|
|
32
|
-
pass
|
|
33
44
|
|
|
34
|
-
|
|
45
|
+
# Raise an error to enforce implementation in subclasses
|
|
46
|
+
raise NotImplementedError("Subclasses must implement the tasks method.")
|
|
47
|
+
|
|
48
|
+
async def onStarted(self, event: SchedulerStarted, schedule: ISchedule):
|
|
35
49
|
"""
|
|
36
|
-
|
|
50
|
+
Handles the event triggered when the scheduler has started successfully.
|
|
51
|
+
|
|
52
|
+
This method is invoked when the scheduler begins its operation. It processes
|
|
53
|
+
the `SchedulerStarted` event and performs any necessary initialization or logging
|
|
54
|
+
tasks associated with the start of the scheduler.
|
|
55
|
+
|
|
56
|
+
Parameters
|
|
57
|
+
----------
|
|
58
|
+
event : SchedulerStarted
|
|
59
|
+
The event object containing details about the scheduler start event.
|
|
60
|
+
schedule : ISchedule
|
|
61
|
+
The schedule instance associated with the started scheduler.
|
|
37
62
|
|
|
38
63
|
Returns
|
|
39
64
|
-------
|
|
40
65
|
None
|
|
41
|
-
This method does not return any value.
|
|
66
|
+
This method does not return any value. It is used for handling the
|
|
67
|
+
scheduler start event and performing related actions.
|
|
42
68
|
|
|
43
69
|
Notes
|
|
44
70
|
-----
|
|
45
|
-
|
|
46
|
-
|
|
71
|
+
This method calls the parent class's `onStarted` method to ensure that
|
|
72
|
+
any base functionality is executed.
|
|
47
73
|
"""
|
|
48
|
-
# Placeholder for logic to execute when the scheduler starts
|
|
49
74
|
pass
|
|
50
75
|
|
|
51
|
-
async def onPaused(self):
|
|
76
|
+
async def onPaused(self, event: SchedulerPaused, schedule: ISchedule):
|
|
52
77
|
"""
|
|
53
|
-
|
|
78
|
+
Handles the event triggered when the scheduler is paused.
|
|
79
|
+
|
|
80
|
+
This method is invoked when the scheduler pauses its operation. It processes
|
|
81
|
+
the `SchedulerPaused` event and performs any necessary actions or logging
|
|
82
|
+
tasks associated with the pause of the scheduler.
|
|
83
|
+
|
|
84
|
+
Parameters
|
|
85
|
+
----------
|
|
86
|
+
event : SchedulerPaused
|
|
87
|
+
The event object containing details about the scheduler pause event.
|
|
88
|
+
schedule : ISchedule
|
|
89
|
+
The schedule instance associated with the paused scheduler.
|
|
54
90
|
|
|
55
91
|
Returns
|
|
56
92
|
-------
|
|
57
93
|
None
|
|
58
|
-
This method does not return any value.
|
|
94
|
+
This method does not return any value. It is used for handling the
|
|
95
|
+
scheduler pause event and performing related actions.
|
|
59
96
|
|
|
60
97
|
Notes
|
|
61
98
|
-----
|
|
62
|
-
|
|
63
|
-
|
|
99
|
+
This method calls the parent class's `onPaused` method to ensure that
|
|
100
|
+
any base functionality is executed.
|
|
64
101
|
"""
|
|
65
|
-
# Placeholder for logic to execute when the scheduler is paused
|
|
66
102
|
pass
|
|
67
103
|
|
|
68
|
-
async def onResumed(self):
|
|
104
|
+
async def onResumed(self, event: SchedulerResumed, schedule: ISchedule):
|
|
69
105
|
"""
|
|
70
|
-
|
|
106
|
+
Handles the event triggered when the scheduler is resumed.
|
|
107
|
+
|
|
108
|
+
This method is invoked when the scheduler resumes its operation after being paused.
|
|
109
|
+
It processes the `SchedulerResumed` event and performs any necessary actions or logging
|
|
110
|
+
tasks associated with the resumption of the scheduler.
|
|
111
|
+
|
|
112
|
+
Parameters
|
|
113
|
+
----------
|
|
114
|
+
event : SchedulerResumed
|
|
115
|
+
The event object containing details about the scheduler resumption, such as the
|
|
116
|
+
timestamp of the resumption and any relevant metadata.
|
|
117
|
+
schedule : ISchedule
|
|
118
|
+
The schedule instance associated with the resumed scheduler, which can be used
|
|
119
|
+
to interact with or modify the scheduler's tasks.
|
|
71
120
|
|
|
72
121
|
Returns
|
|
73
122
|
-------
|
|
74
123
|
None
|
|
75
|
-
This method does not return any value.
|
|
124
|
+
This method does not return any value. It is used for handling the scheduler
|
|
125
|
+
resumption event and performing related actions.
|
|
76
126
|
|
|
77
127
|
Notes
|
|
78
128
|
-----
|
|
79
|
-
|
|
80
|
-
scheduler
|
|
129
|
+
This method calls the parent class's `onResumed` method to ensure that any base
|
|
130
|
+
functionality is executed. This allows the scheduler to maintain its default behavior
|
|
131
|
+
while enabling additional custom actions during the resumption process.
|
|
81
132
|
"""
|
|
82
|
-
# Placeholder for logic to execute when the scheduler is resumed
|
|
83
133
|
pass
|
|
84
134
|
|
|
85
|
-
async def onFinalized(self):
|
|
135
|
+
async def onFinalized(self, event: SchedulerShutdown, schedule: ISchedule):
|
|
86
136
|
"""
|
|
87
|
-
|
|
137
|
+
Handles the event triggered when the scheduler has been finalized.
|
|
138
|
+
|
|
139
|
+
This method is invoked after the scheduler has completed its shutdown process.
|
|
140
|
+
It processes the `SchedulerShutdown` event and performs any necessary cleanup
|
|
141
|
+
or logging tasks associated with the finalization of the scheduler.
|
|
142
|
+
|
|
143
|
+
Parameters
|
|
144
|
+
----------
|
|
145
|
+
event : SchedulerShutdown
|
|
146
|
+
The event object containing details about the scheduler shutdown, such as
|
|
147
|
+
the timestamp of the shutdown and any relevant metadata.
|
|
148
|
+
schedule : ISchedule
|
|
149
|
+
The schedule instance associated with the finalized scheduler, which can be
|
|
150
|
+
used to interact with or inspect the scheduler's tasks.
|
|
88
151
|
|
|
89
152
|
Returns
|
|
90
153
|
-------
|
|
91
154
|
None
|
|
92
|
-
This method does not return any value.
|
|
155
|
+
This method does not return any value. It is used for handling the scheduler
|
|
156
|
+
shutdown event and performing related actions.
|
|
93
157
|
|
|
94
158
|
Notes
|
|
95
159
|
-----
|
|
96
|
-
|
|
160
|
+
This method calls the parent class's `onFinalized` method to ensure that any base
|
|
161
|
+
functionality is executed. This allows the scheduler to maintain its default behavior
|
|
162
|
+
while enabling additional custom actions during the finalization process.
|
|
97
163
|
"""
|
|
98
|
-
# Placeholder for logic to execute when the scheduler is finalized
|
|
99
164
|
pass
|
|
100
165
|
|
|
101
|
-
async def onError(self,
|
|
166
|
+
async def onError(self, event: JobError, schedule: ISchedule):
|
|
102
167
|
"""
|
|
103
|
-
Handles
|
|
168
|
+
Handles the event triggered when a job encounters an error during execution.
|
|
169
|
+
|
|
170
|
+
This method is invoked when a job fails due to an exception. It processes the `JobError`
|
|
171
|
+
event and performs any necessary actions, such as logging the error details or notifying
|
|
172
|
+
relevant systems about the failure.
|
|
104
173
|
|
|
105
174
|
Parameters
|
|
106
175
|
----------
|
|
107
|
-
|
|
108
|
-
The
|
|
176
|
+
event : JobError
|
|
177
|
+
The event object containing details about the job error, including the job ID,
|
|
178
|
+
the exception that occurred, and any relevant metadata.
|
|
179
|
+
schedule : ISchedule
|
|
180
|
+
The schedule instance associated with the job, which can be used to interact with
|
|
181
|
+
or modify the scheduler's tasks.
|
|
109
182
|
|
|
110
183
|
Returns
|
|
111
184
|
-------
|
|
112
185
|
None
|
|
113
|
-
This method does not return any value.
|
|
186
|
+
This method does not return any value. It is used for handling the job error event
|
|
187
|
+
and performing related actions, such as logging or cleanup.
|
|
114
188
|
|
|
115
189
|
Notes
|
|
116
190
|
-----
|
|
117
|
-
|
|
191
|
+
This method calls the parent class's `onError` method to ensure that any base functionality
|
|
192
|
+
is executed. This allows the scheduler to maintain its default behavior while enabling
|
|
193
|
+
additional custom actions during error handling.
|
|
118
194
|
"""
|
|
119
|
-
# Placeholder for logic to handle errors in the scheduler
|
|
120
195
|
pass
|
|
@@ -1,140 +1,189 @@
|
|
|
1
1
|
from abc import ABC, abstractmethod
|
|
2
|
-
from datetime import datetime
|
|
3
2
|
from orionis.console.contracts.schedule import ISchedule
|
|
3
|
+
from orionis.console.entities.job_error import JobError
|
|
4
|
+
from orionis.console.entities.scheduler_paused import SchedulerPaused
|
|
5
|
+
from orionis.console.entities.scheduler_resumed import SchedulerResumed
|
|
6
|
+
from orionis.console.entities.scheduler_shutdown import SchedulerShutdown
|
|
7
|
+
from orionis.console.entities.scheduler_started import SchedulerStarted
|
|
4
8
|
|
|
5
9
|
class IBaseScheduler(ABC):
|
|
6
10
|
|
|
7
|
-
# Pause Global Scheduler at a specific time
|
|
8
|
-
PAUSE_AT: datetime = None
|
|
9
|
-
|
|
10
|
-
# Resume Global Scheduler at a specific time
|
|
11
|
-
RESUME_AT: datetime = None
|
|
12
|
-
|
|
13
|
-
# Finalize Global Scheduler at a specific time
|
|
14
|
-
FINALIZE_AT: datetime = None
|
|
15
|
-
|
|
16
11
|
@abstractmethod
|
|
17
12
|
async def tasks(self, schedule: ISchedule):
|
|
18
13
|
"""
|
|
19
14
|
Defines and registers scheduled tasks for the application.
|
|
20
15
|
|
|
16
|
+
This method is responsible for setting up the tasks that the scheduler will execute.
|
|
17
|
+
It uses the provided `schedule` object to define the properties and behavior of each task.
|
|
18
|
+
|
|
21
19
|
Parameters
|
|
22
20
|
----------
|
|
23
21
|
schedule : ISchedule
|
|
24
|
-
The schedule object used to define and register scheduled commands.
|
|
25
|
-
This object provides methods to add tasks to the scheduler.
|
|
22
|
+
The schedule object used to define and register scheduled commands.
|
|
26
23
|
|
|
27
24
|
Returns
|
|
28
25
|
-------
|
|
29
26
|
None
|
|
30
|
-
This method does not return any value. It is
|
|
31
|
-
by subclasses to specify scheduled tasks.
|
|
27
|
+
This method does not return any value. It is used solely for task registration.
|
|
32
28
|
|
|
33
29
|
Notes
|
|
34
30
|
-----
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
31
|
+
Subclasses must override this method to implement their specific task scheduling logic.
|
|
32
|
+
The method should define the tasks, their execution intervals, and any additional
|
|
33
|
+
properties or constraints required for the tasks.
|
|
38
34
|
"""
|
|
39
|
-
# Abstract method to be implemented by subclasses for task registration
|
|
40
35
|
pass
|
|
41
36
|
|
|
42
37
|
@abstractmethod
|
|
43
|
-
async def onStarted(self):
|
|
38
|
+
async def onStarted(self, event: SchedulerStarted, schedule: ISchedule):
|
|
44
39
|
"""
|
|
45
|
-
|
|
40
|
+
Handles the event triggered when the scheduler has started successfully.
|
|
41
|
+
|
|
42
|
+
This method is invoked when the scheduler begins its operation. It processes
|
|
43
|
+
the `SchedulerStarted` event and performs any necessary initialization or logging
|
|
44
|
+
tasks associated with the start of the scheduler.
|
|
45
|
+
|
|
46
|
+
Parameters
|
|
47
|
+
----------
|
|
48
|
+
event : SchedulerStarted
|
|
49
|
+
The event object containing details about the scheduler start event.
|
|
50
|
+
schedule : ISchedule
|
|
51
|
+
The schedule instance associated with the started scheduler.
|
|
46
52
|
|
|
47
53
|
Returns
|
|
48
54
|
-------
|
|
49
55
|
None
|
|
50
|
-
This method does not return any value.
|
|
56
|
+
This method does not return any value. It is used for handling the
|
|
57
|
+
scheduler start event and performing related actions.
|
|
51
58
|
|
|
52
59
|
Notes
|
|
53
60
|
-----
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
resources or logging the start event.
|
|
61
|
+
This method calls the parent class's `onStarted` method to ensure that
|
|
62
|
+
any base functionality is executed.
|
|
57
63
|
"""
|
|
58
|
-
# Abstract method to define behavior when the scheduler starts
|
|
59
64
|
pass
|
|
60
65
|
|
|
61
66
|
@abstractmethod
|
|
62
|
-
async def onPaused(self):
|
|
67
|
+
async def onPaused(self, event: SchedulerPaused, schedule: ISchedule):
|
|
63
68
|
"""
|
|
64
|
-
|
|
69
|
+
Handles the event triggered when the scheduler is paused.
|
|
70
|
+
|
|
71
|
+
This method is invoked when the scheduler pauses its operation. It processes
|
|
72
|
+
the `SchedulerPaused` event and performs any necessary actions or logging
|
|
73
|
+
tasks associated with the pause of the scheduler.
|
|
74
|
+
|
|
75
|
+
Parameters
|
|
76
|
+
----------
|
|
77
|
+
event : SchedulerPaused
|
|
78
|
+
The event object containing details about the scheduler pause event.
|
|
79
|
+
schedule : ISchedule
|
|
80
|
+
The schedule instance associated with the paused scheduler.
|
|
65
81
|
|
|
66
82
|
Returns
|
|
67
83
|
-------
|
|
68
84
|
None
|
|
69
|
-
This method does not return any value.
|
|
85
|
+
This method does not return any value. It is used for handling the
|
|
86
|
+
scheduler pause event and performing related actions.
|
|
70
87
|
|
|
71
88
|
Notes
|
|
72
89
|
-----
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
state or logging the pause event.
|
|
90
|
+
This method calls the parent class's `onPaused` method to ensure that
|
|
91
|
+
any base functionality is executed.
|
|
76
92
|
"""
|
|
77
|
-
# Abstract method to define behavior when the scheduler is paused
|
|
78
93
|
pass
|
|
79
94
|
|
|
80
95
|
@abstractmethod
|
|
81
|
-
async def onResumed(self):
|
|
96
|
+
async def onResumed(self, event: SchedulerResumed, schedule: ISchedule):
|
|
82
97
|
"""
|
|
83
|
-
|
|
98
|
+
Handles the event triggered when the scheduler is resumed.
|
|
99
|
+
|
|
100
|
+
This method is invoked when the scheduler resumes its operation after being paused.
|
|
101
|
+
It processes the `SchedulerResumed` event and performs any necessary actions or logging
|
|
102
|
+
tasks associated with the resumption of the scheduler.
|
|
103
|
+
|
|
104
|
+
Parameters
|
|
105
|
+
----------
|
|
106
|
+
event : SchedulerResumed
|
|
107
|
+
The event object containing details about the scheduler resumption, such as the
|
|
108
|
+
timestamp of the resumption and any relevant metadata.
|
|
109
|
+
schedule : ISchedule
|
|
110
|
+
The schedule instance associated with the resumed scheduler, which can be used
|
|
111
|
+
to interact with or modify the scheduler's tasks.
|
|
84
112
|
|
|
85
113
|
Returns
|
|
86
114
|
-------
|
|
87
115
|
None
|
|
88
|
-
This method does not return any value.
|
|
116
|
+
This method does not return any value. It is used for handling the scheduler
|
|
117
|
+
resumption event and performing related actions.
|
|
89
118
|
|
|
90
119
|
Notes
|
|
91
120
|
-----
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
121
|
+
This method calls the parent class's `onResumed` method to ensure that any base
|
|
122
|
+
functionality is executed. This allows the scheduler to maintain its default behavior
|
|
123
|
+
while enabling additional custom actions during the resumption process.
|
|
95
124
|
"""
|
|
96
|
-
# Abstract method to define behavior when the scheduler is resumed
|
|
97
125
|
pass
|
|
98
126
|
|
|
99
127
|
@abstractmethod
|
|
100
|
-
async def onFinalized(self):
|
|
128
|
+
async def onFinalized(self, event: SchedulerShutdown, schedule: ISchedule):
|
|
101
129
|
"""
|
|
102
|
-
|
|
130
|
+
Handles the event triggered when the scheduler has been finalized.
|
|
131
|
+
|
|
132
|
+
This method is invoked after the scheduler has completed its shutdown process.
|
|
133
|
+
It processes the `SchedulerShutdown` event and performs any necessary cleanup
|
|
134
|
+
or logging tasks associated with the finalization of the scheduler.
|
|
135
|
+
|
|
136
|
+
Parameters
|
|
137
|
+
----------
|
|
138
|
+
event : SchedulerShutdown
|
|
139
|
+
The event object containing details about the scheduler shutdown, such as
|
|
140
|
+
the timestamp of the shutdown and any relevant metadata.
|
|
141
|
+
schedule : ISchedule
|
|
142
|
+
The schedule instance associated with the finalized scheduler, which can be
|
|
143
|
+
used to interact with or inspect the scheduler's tasks.
|
|
103
144
|
|
|
104
145
|
Returns
|
|
105
146
|
-------
|
|
106
147
|
None
|
|
107
|
-
This method does not return any value.
|
|
148
|
+
This method does not return any value. It is used for handling the scheduler
|
|
149
|
+
shutdown event and performing related actions.
|
|
108
150
|
|
|
109
151
|
Notes
|
|
110
152
|
-----
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
153
|
+
This method calls the parent class's `onFinalized` method to ensure that any base
|
|
154
|
+
functionality is executed. This allows the scheduler to maintain its default behavior
|
|
155
|
+
while enabling additional custom actions during the finalization process.
|
|
114
156
|
"""
|
|
115
|
-
# Abstract method to define behavior when the scheduler is finalized
|
|
116
157
|
pass
|
|
117
158
|
|
|
118
159
|
@abstractmethod
|
|
119
|
-
async def onError(self,
|
|
160
|
+
async def onError(self, event: JobError, schedule: ISchedule):
|
|
120
161
|
"""
|
|
121
|
-
Handles
|
|
162
|
+
Handles the event triggered when a job encounters an error during execution.
|
|
163
|
+
|
|
164
|
+
This method is invoked when a job fails due to an exception. It processes the `JobError`
|
|
165
|
+
event and performs any necessary actions, such as logging the error details or notifying
|
|
166
|
+
relevant systems about the failure.
|
|
122
167
|
|
|
123
168
|
Parameters
|
|
124
169
|
----------
|
|
125
|
-
|
|
126
|
-
The
|
|
170
|
+
event : JobError
|
|
171
|
+
The event object containing details about the job error, including the job ID,
|
|
172
|
+
the exception that occurred, and any relevant metadata.
|
|
173
|
+
schedule : ISchedule
|
|
174
|
+
The schedule instance associated with the job, which can be used to interact with
|
|
175
|
+
or modify the scheduler's tasks.
|
|
127
176
|
|
|
128
177
|
Returns
|
|
129
178
|
-------
|
|
130
179
|
None
|
|
131
|
-
This method does not return any value.
|
|
180
|
+
This method does not return any value. It is used for handling the job error event
|
|
181
|
+
and performing related actions, such as logging or cleanup.
|
|
132
182
|
|
|
133
183
|
Notes
|
|
134
184
|
-----
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
185
|
+
This method calls the parent class's `onError` method to ensure that any base functionality
|
|
186
|
+
is executed. This allows the scheduler to maintain its default behavior while enabling
|
|
187
|
+
additional custom actions during error handling.
|
|
138
188
|
"""
|
|
139
|
-
# Abstract method to define behavior for handling errors in the scheduler
|
|
140
189
|
pass
|
|
@@ -3,6 +3,7 @@ from datetime import datetime
|
|
|
3
3
|
import logging
|
|
4
4
|
from typing import Dict, List, Optional, Union
|
|
5
5
|
import pytz
|
|
6
|
+
from apscheduler.triggers.date import DateTrigger
|
|
6
7
|
from apscheduler.events import (
|
|
7
8
|
EVENT_SCHEDULER_STARTED,
|
|
8
9
|
EVENT_SCHEDULER_PAUSED,
|
|
@@ -288,7 +289,7 @@ class Scheduler(ISchedule):
|
|
|
288
289
|
# Return the Event instance for further scheduling configuration
|
|
289
290
|
return self.__events[signature]
|
|
290
291
|
|
|
291
|
-
def
|
|
292
|
+
def __subscribeListeners(
|
|
292
293
|
self
|
|
293
294
|
) -> None:
|
|
294
295
|
"""
|
|
@@ -366,12 +367,16 @@ class Scheduler(ISchedule):
|
|
|
366
367
|
|
|
367
368
|
# Ensure the listener is callable before invoking it
|
|
368
369
|
if callable(listener):
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
asyncio.
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
370
|
+
try:
|
|
371
|
+
# If the listener is a coroutine, schedule it as an asyncio task
|
|
372
|
+
if asyncio.iscoroutinefunction(listener):
|
|
373
|
+
asyncio.create_task(listener(event_data, self))
|
|
374
|
+
# Otherwise, invoke the listener directly as a regular function
|
|
375
|
+
else:
|
|
376
|
+
listener(event_data, self)
|
|
377
|
+
except Exception as e:
|
|
378
|
+
# Log any exceptions that occur during listener invocation
|
|
379
|
+
self.__logger.error(f"Error invoking global listener for event '{scheduler_event}': {str(e)}")
|
|
375
380
|
|
|
376
381
|
def __taskCallableListener(
|
|
377
382
|
self,
|
|
@@ -411,6 +416,10 @@ class Scheduler(ISchedule):
|
|
|
411
416
|
if not isinstance(listening_vent, ListeningEvent):
|
|
412
417
|
raise CLIOrionisValueError("The event must be an instance of ListeningEvent.")
|
|
413
418
|
|
|
419
|
+
# Validate that event_data is not None and has a job_id attribute
|
|
420
|
+
if event_data is None or not hasattr(event_data, 'job_id'):
|
|
421
|
+
return
|
|
422
|
+
|
|
414
423
|
# Retrieve the global identifier for the event from the ListeningEvent enum
|
|
415
424
|
scheduler_event = listening_vent.value
|
|
416
425
|
|
|
@@ -427,13 +436,17 @@ class Scheduler(ISchedule):
|
|
|
427
436
|
if hasattr(listener, scheduler_event) and callable(getattr(listener, scheduler_event)):
|
|
428
437
|
listener_method = getattr(listener, scheduler_event)
|
|
429
438
|
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
439
|
+
try:
|
|
440
|
+
# Invoke the listener method, handling both coroutine and regular functions
|
|
441
|
+
if asyncio.iscoroutinefunction(listener_method):
|
|
442
|
+
# Schedule the coroutine listener method as an asyncio task
|
|
443
|
+
asyncio.create_task(listener_method(event_data, self))
|
|
444
|
+
else:
|
|
445
|
+
# Call the regular listener method directly
|
|
446
|
+
listener_method(event_data, self)
|
|
447
|
+
except Exception as e:
|
|
448
|
+
# Log any exceptions that occur during listener invocation
|
|
449
|
+
self.__logger.error(f"Error invoking listener method '{scheduler_event}' for job '{event_data.job_id}': {str(e)}")
|
|
437
450
|
|
|
438
451
|
def __startedListener(
|
|
439
452
|
self,
|
|
@@ -524,7 +537,7 @@ class Scheduler(ISchedule):
|
|
|
524
537
|
# Log an informational message indicating that the scheduler has been paused
|
|
525
538
|
self.__logger.info(message)
|
|
526
539
|
|
|
527
|
-
# Check if a listener is registered for the scheduler
|
|
540
|
+
# Check if a listener is registered for the scheduler paused event
|
|
528
541
|
self.__globalCallableListener(event, ListeningEvent.SCHEDULER_PAUSED)
|
|
529
542
|
|
|
530
543
|
def __resumedListener(
|
|
@@ -561,7 +574,7 @@ class Scheduler(ISchedule):
|
|
|
561
574
|
# Log an informational message indicating that the scheduler has resumed
|
|
562
575
|
self.__logger.info(message)
|
|
563
576
|
|
|
564
|
-
# Check if a listener is registered for the scheduler
|
|
577
|
+
# Check if a listener is registered for the scheduler resumed event
|
|
565
578
|
self.__globalCallableListener(event, ListeningEvent.SCHEDULER_RESUMED)
|
|
566
579
|
|
|
567
580
|
def __shutdownListener(
|
|
@@ -598,7 +611,7 @@ class Scheduler(ISchedule):
|
|
|
598
611
|
# Log an informational message indicating that the scheduler has shut down
|
|
599
612
|
self.__logger.info(message)
|
|
600
613
|
|
|
601
|
-
# Check if a listener is registered for the scheduler
|
|
614
|
+
# Check if a listener is registered for the scheduler shutdown event
|
|
602
615
|
self.__globalCallableListener(event, ListeningEvent.SCHEDULER_SHUTDOWN)
|
|
603
616
|
|
|
604
617
|
def __errorListener(
|
|
@@ -878,11 +891,11 @@ class Scheduler(ISchedule):
|
|
|
878
891
|
self.__jobs.append(entity)
|
|
879
892
|
|
|
880
893
|
# Create a unique key for the job based on its signature
|
|
894
|
+
def create_job_func(cmd, args_list):
|
|
895
|
+
return lambda: self.__reactor.call(cmd, args_list)
|
|
896
|
+
|
|
881
897
|
self.__scheduler.add_job(
|
|
882
|
-
func=
|
|
883
|
-
command,
|
|
884
|
-
args
|
|
885
|
-
),
|
|
898
|
+
func=create_job_func(signature, list(entity.args)),
|
|
886
899
|
trigger=entity.trigger,
|
|
887
900
|
id=signature,
|
|
888
901
|
name=signature,
|
|
@@ -979,8 +992,7 @@ class Scheduler(ISchedule):
|
|
|
979
992
|
# Add a job to the scheduler to pause it at the specified datetime
|
|
980
993
|
self.__scheduler.add_job(
|
|
981
994
|
func=self.__scheduler.pause, # Function to pause the scheduler
|
|
982
|
-
trigger=
|
|
983
|
-
run_date=at, # The datetime at which the job will run
|
|
995
|
+
trigger=DateTrigger(run_date=at), # Trigger type is 'date' for one-time execution
|
|
984
996
|
id=f"pause_scheduler_at_{at.isoformat()}", # Unique job ID based on the datetime
|
|
985
997
|
name=f"Pause Scheduler at {at.isoformat()}", # Descriptive name for the job
|
|
986
998
|
replace_existing=True # Replace any existing job with the same ID
|
|
@@ -1022,8 +1034,7 @@ class Scheduler(ISchedule):
|
|
|
1022
1034
|
# Add a job to the scheduler to resume it at the specified datetime
|
|
1023
1035
|
self.__scheduler.add_job(
|
|
1024
1036
|
func=self.__scheduler.resume, # Function to resume the scheduler
|
|
1025
|
-
trigger=
|
|
1026
|
-
run_date=at, # The datetime at which the job will run
|
|
1037
|
+
trigger=DateTrigger(run_date=at), # Trigger type is 'date' for one-time execution
|
|
1027
1038
|
id=f"resume_scheduler_at_{at.isoformat()}", # Unique job ID based on the datetime
|
|
1028
1039
|
name=f"Resume Scheduler at {at.isoformat()}", # Descriptive name for the job
|
|
1029
1040
|
replace_existing=True # Replace any existing job with the same ID
|
|
@@ -1065,8 +1076,7 @@ class Scheduler(ISchedule):
|
|
|
1065
1076
|
# Add a job to the scheduler to shut it down at the specified datetime
|
|
1066
1077
|
self.__scheduler.add_job(
|
|
1067
1078
|
func=self.__scheduler.shutdown, # Function to shut down the scheduler
|
|
1068
|
-
trigger=
|
|
1069
|
-
run_date=at, # The datetime at which the job will run
|
|
1079
|
+
trigger=DateTrigger(run_date=at), # Trigger type is 'date' for one-time execution
|
|
1070
1080
|
id=f"shutdown_scheduler_at_{at.isoformat()}", # Unique job ID based on the datetime
|
|
1071
1081
|
name=f"Shutdown Scheduler at {at.isoformat()}", # Descriptive name for the job
|
|
1072
1082
|
replace_existing=True # Replace any existing job with the same ID
|
|
@@ -1093,7 +1103,7 @@ class Scheduler(ISchedule):
|
|
|
1093
1103
|
self.__loadEvents()
|
|
1094
1104
|
|
|
1095
1105
|
# Subscribe to scheduler events for monitoring and handling
|
|
1096
|
-
self.
|
|
1106
|
+
self.__subscribeListeners()
|
|
1097
1107
|
|
|
1098
1108
|
# Ensure we're in an asyncio context
|
|
1099
1109
|
asyncio.get_running_loop()
|
orionis/metadata/framework.py
CHANGED
|
@@ -8,7 +8,7 @@ orionis/console/args/enums/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJ
|
|
|
8
8
|
orionis/console/args/enums/actions.py,sha256=S3T-vWS6DJSGtANrq3od3-90iYAjPvJwaOZ2V02y34c,1222
|
|
9
9
|
orionis/console/base/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
10
10
|
orionis/console/base/command.py,sha256=OM4xqVgpv_1RZVyVG8BzOHl1sP9FT5mPUwZjMil8IRg,6637
|
|
11
|
-
orionis/console/base/scheduler.py,sha256=
|
|
11
|
+
orionis/console/base/scheduler.py,sha256=w86p-4KjfMqMcGlQBsmiBASpzv33M-PWLbgYza7Um9g,8030
|
|
12
12
|
orionis/console/base/scheduler_event_listener.py,sha256=5qWPmf6jmiRwUz6U1ZvpQCG5eovOpeCl0KAb8kKDkfU,3905
|
|
13
13
|
orionis/console/commands/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
14
14
|
orionis/console/commands/cache.py,sha256=8DsYoRzSBLn0P9qkGVItRbo0R6snWBDBg0_Xa7tmVhs,2322
|
|
@@ -26,7 +26,7 @@ orionis/console/contracts/kernel.py,sha256=mh4LlhEYHh3FuGZZQ0GBhD6ZLa5YQvaNj2r01
|
|
|
26
26
|
orionis/console/contracts/reactor.py,sha256=Xeq7Zrw6WE5MV_XOQfiQEchAFbb6-0TjLpjWOxYW--g,4554
|
|
27
27
|
orionis/console/contracts/schedule.py,sha256=17cfPYtLo-jqF8FxYOhh4epJZnxw5mMPuLGaWoUwxL4,12171
|
|
28
28
|
orionis/console/contracts/schedule_event_listener.py,sha256=G-Ye9YIzfeXFcJD1jqNOy7Cj_-VQGq0ynXZCTPTp7Mc,11550
|
|
29
|
-
orionis/console/contracts/scheduler.py,sha256=
|
|
29
|
+
orionis/console/contracts/scheduler.py,sha256=OW-a_YDDNPrenYT9z8Tv71VjyZ1aSzqzqhTBhTCZhGM,7698
|
|
30
30
|
orionis/console/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
31
|
orionis/console/core/reactor.py,sha256=JlxNiqmyzAqiS21hxOMD5ELiDNPzmGHYDNrdlaMvYuI,30409
|
|
32
32
|
orionis/console/dumper/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -81,7 +81,7 @@ orionis/console/request/cli_request.py,sha256=7-sgYmNUCipuHLVAwWLJiHv0cJCDmsM1Lu
|
|
|
81
81
|
orionis/console/tasks/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
82
82
|
orionis/console/tasks/event.py,sha256=l4J-HEPaj1mxB_PYQMgG9dRHUe01wUag8fKLLnR2N2M,164395
|
|
83
83
|
orionis/console/tasks/listener.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
84
|
-
orionis/console/tasks/schedule.py,sha256=
|
|
84
|
+
orionis/console/tasks/schedule.py,sha256=pUU9583IfF4_SSR2QShOC9emYIRVZIw55L0I231OCzE,57354
|
|
85
85
|
orionis/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
86
86
|
orionis/container/container.py,sha256=aF_b6lTUpG4YCo9yFJEzsntTdIzgMMXFW5LyWqAJVBQ,87987
|
|
87
87
|
orionis/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -239,7 +239,7 @@ orionis/foundation/providers/scheduler_provider.py,sha256=72SoixFog9IOE9Ve9Xcfw6
|
|
|
239
239
|
orionis/foundation/providers/testing_provider.py,sha256=SrJRpdvcblx9WvX7x9Y3zc7OQfiTf7la0HAJrm2ESlE,3725
|
|
240
240
|
orionis/foundation/providers/workers_provider.py,sha256=oa_2NIDH6UxZrtuGkkoo_zEoNIMGgJ46vg5CCgAm7wI,3926
|
|
241
241
|
orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
242
|
-
orionis/metadata/framework.py,sha256=
|
|
242
|
+
orionis/metadata/framework.py,sha256=VeR527XQrx3ObhbRQw5nqCi2-UqaggUmArNd_JGPPIw,4109
|
|
243
243
|
orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
|
|
244
244
|
orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
245
245
|
orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -415,7 +415,7 @@ orionis/test/validators/web_report.py,sha256=n9BfzOZz6aEiNTypXcwuWbFRG0OdHNSmCNu
|
|
|
415
415
|
orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnIfJYgc,1206
|
|
416
416
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
417
417
|
orionis/test/view/render.py,sha256=f-zNhtKSg9R5Njqujbg2l2amAs2-mRVESneLIkWOZjU,4082
|
|
418
|
-
orionis-0.
|
|
418
|
+
orionis-0.519.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
|
|
419
419
|
tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
420
420
|
tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
421
421
|
tests/container/context/test_manager.py,sha256=wOwXpl9rHNfTTexa9GBKYMwK0_-KSQPbI-AEyGNkmAE,1356
|
|
@@ -561,8 +561,8 @@ tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
561
561
|
tests/testing/validators/test_testing_validators.py,sha256=WPo5GxTP6xE-Dw3X1vZoqOMpb6HhokjNSbgDsDRDvy4,16588
|
|
562
562
|
tests/testing/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
563
563
|
tests/testing/view/test_render.py,sha256=tnnMBwS0iKUIbogLvu-7Rii50G6Koddp3XT4wgdFEYM,1050
|
|
564
|
-
orionis-0.
|
|
565
|
-
orionis-0.
|
|
566
|
-
orionis-0.
|
|
567
|
-
orionis-0.
|
|
568
|
-
orionis-0.
|
|
564
|
+
orionis-0.519.0.dist-info/METADATA,sha256=XE_Lo42wgelgD9vBLaDtuWArC0hUaAI-nqGUiBTZvSs,4801
|
|
565
|
+
orionis-0.519.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
566
|
+
orionis-0.519.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
|
567
|
+
orionis-0.519.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
568
|
+
orionis-0.519.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|