orionis 0.523.0__py3-none-any.whl → 0.524.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/tasks/schedule.py +71 -88
- orionis/metadata/framework.py +1 -1
- {orionis-0.523.0.dist-info → orionis-0.524.0.dist-info}/METADATA +1 -1
- {orionis-0.523.0.dist-info → orionis-0.524.0.dist-info}/RECORD +8 -8
- {orionis-0.523.0.dist-info → orionis-0.524.0.dist-info}/WHEEL +0 -0
- {orionis-0.523.0.dist-info → orionis-0.524.0.dist-info}/licenses/LICENCE +0 -0
- {orionis-0.523.0.dist-info → orionis-0.524.0.dist-info}/top_level.txt +0 -0
- {orionis-0.523.0.dist-info → orionis-0.524.0.dist-info}/zip-safe +0 -0
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
from datetime import datetime
|
|
3
3
|
import logging
|
|
4
|
-
from typing import Dict, List, Optional, Union
|
|
4
|
+
from typing import Any, Awaitable, Callable, Dict, List, Optional, Union
|
|
5
5
|
import pytz
|
|
6
6
|
from apscheduler.triggers.date import DateTrigger
|
|
7
7
|
from apscheduler.events import (
|
|
@@ -401,7 +401,7 @@ class Scheduler(ISchedule):
|
|
|
401
401
|
except RuntimeError:
|
|
402
402
|
|
|
403
403
|
# Message indicating that the listener could not be invoked
|
|
404
|
-
error_msg = f"Cannot run
|
|
404
|
+
error_msg = f"Cannot run listener for '{scheduler_event}': no event loop running"
|
|
405
405
|
|
|
406
406
|
# Log the error message
|
|
407
407
|
self.__logger.error(error_msg)
|
|
@@ -600,74 +600,6 @@ class Scheduler(ISchedule):
|
|
|
600
600
|
# Log an informational message indicating that the scheduler has started
|
|
601
601
|
self.__logger.info(f"Orionis Scheduler started successfully at {now}.")
|
|
602
602
|
|
|
603
|
-
def __pausedListener(
|
|
604
|
-
self,
|
|
605
|
-
event: SchedulerPaused
|
|
606
|
-
) -> None:
|
|
607
|
-
"""
|
|
608
|
-
Handle the scheduler paused event for logging and invoking registered listeners.
|
|
609
|
-
|
|
610
|
-
This method is triggered when the scheduler is paused. It logs an informational
|
|
611
|
-
message indicating that the scheduler has been paused successfully and displays
|
|
612
|
-
a formatted message on the rich console. If a listener is registered for the
|
|
613
|
-
scheduler paused event, it invokes the listener with the event details.
|
|
614
|
-
|
|
615
|
-
Parameters
|
|
616
|
-
----------
|
|
617
|
-
event : SchedulerPaused
|
|
618
|
-
An event object containing details about the scheduler paused event.
|
|
619
|
-
|
|
620
|
-
Returns
|
|
621
|
-
-------
|
|
622
|
-
None
|
|
623
|
-
This method does not return any value. It performs logging, displays
|
|
624
|
-
a message on the console, and invokes any registered listener for the
|
|
625
|
-
scheduler paused event.
|
|
626
|
-
"""
|
|
627
|
-
|
|
628
|
-
# Get the current time in the configured timezone
|
|
629
|
-
now = self.__getCurrentTime()
|
|
630
|
-
|
|
631
|
-
# Check if a listener is registered for the scheduler paused event
|
|
632
|
-
self.__globalCallableListener(event, ListeningEvent.SCHEDULER_PAUSED)
|
|
633
|
-
|
|
634
|
-
# Log an informational message indicating that the scheduler has been paused
|
|
635
|
-
self.__logger.info(f"Orionis Scheduler paused successfully at {now}.")
|
|
636
|
-
|
|
637
|
-
def __resumedListener(
|
|
638
|
-
self,
|
|
639
|
-
event: SchedulerResumed
|
|
640
|
-
) -> None:
|
|
641
|
-
"""
|
|
642
|
-
Handle the scheduler resumed event for logging and invoking registered listeners.
|
|
643
|
-
|
|
644
|
-
This method is triggered when the scheduler resumes from a paused state. It logs an informational
|
|
645
|
-
message indicating that the scheduler has resumed successfully and displays a formatted message
|
|
646
|
-
on the rich console. If a listener is registered for the scheduler resumed event, it invokes
|
|
647
|
-
the listener with the event details.
|
|
648
|
-
|
|
649
|
-
Parameters
|
|
650
|
-
----------
|
|
651
|
-
event : SchedulerResumed
|
|
652
|
-
An event object containing details about the scheduler resumed event.
|
|
653
|
-
|
|
654
|
-
Returns
|
|
655
|
-
-------
|
|
656
|
-
None
|
|
657
|
-
This method does not return any value. It performs logging, displays
|
|
658
|
-
a message on the console, and invokes any registered listener for the
|
|
659
|
-
scheduler resumed event.
|
|
660
|
-
"""
|
|
661
|
-
|
|
662
|
-
# Get the current time in the configured timezone
|
|
663
|
-
now = self.__getCurrentTime()
|
|
664
|
-
|
|
665
|
-
# Check if a listener is registered for the scheduler resumed event
|
|
666
|
-
self.__globalCallableListener(event, ListeningEvent.SCHEDULER_RESUMED)
|
|
667
|
-
|
|
668
|
-
# Log an informational message indicating that the scheduler has resumed
|
|
669
|
-
self.__logger.info(f"Orionis Scheduler resumed successfully at {now}.")
|
|
670
|
-
|
|
671
603
|
def __shutdownListener(
|
|
672
604
|
self,
|
|
673
605
|
event: SchedulerShutdown
|
|
@@ -1038,6 +970,53 @@ class Scheduler(ISchedule):
|
|
|
1038
970
|
# Register the listener for the specified event in the internal listeners dictionary
|
|
1039
971
|
self.__listeners[event] = listener
|
|
1040
972
|
|
|
973
|
+
def wrapAsyncFunction(
|
|
974
|
+
self,
|
|
975
|
+
func: Callable[..., Awaitable[Any]]
|
|
976
|
+
) -> Callable[..., Any]:
|
|
977
|
+
"""
|
|
978
|
+
Wrap an asynchronous function to be called in a synchronous context.
|
|
979
|
+
|
|
980
|
+
This method takes an asynchronous function (a coroutine) and returns a synchronous
|
|
981
|
+
wrapper function that can be called in a non-async context. The wrapper function
|
|
982
|
+
ensures that the asynchronous function is executed within the appropriate event loop.
|
|
983
|
+
|
|
984
|
+
Parameters
|
|
985
|
+
----------
|
|
986
|
+
func : Callable[..., Awaitable[Any]]
|
|
987
|
+
The asynchronous function (coroutine) to be wrapped. This function should be
|
|
988
|
+
defined using the `async def` syntax and return an awaitable object.
|
|
989
|
+
|
|
990
|
+
Returns
|
|
991
|
+
-------
|
|
992
|
+
Callable[..., Any]
|
|
993
|
+
A synchronous wrapper function that can be called in a non-async context.
|
|
994
|
+
When invoked, this wrapper will execute the original asynchronous function
|
|
995
|
+
within the appropriate event loop.
|
|
996
|
+
|
|
997
|
+
Raises
|
|
998
|
+
------
|
|
999
|
+
ValueError
|
|
1000
|
+
If the provided `func` is not an asynchronous function (coroutine).
|
|
1001
|
+
"""
|
|
1002
|
+
|
|
1003
|
+
# Define a synchronous wrapper function
|
|
1004
|
+
def sync_wrapper(*args, **kwargs) -> Any:
|
|
1005
|
+
try:
|
|
1006
|
+
# Try to get the current event loop
|
|
1007
|
+
loop = asyncio.get_event_loop()
|
|
1008
|
+
if loop.is_running():
|
|
1009
|
+
# If the loop is already running, create a task for the coroutine
|
|
1010
|
+
return asyncio.create_task(func(*args, **kwargs))
|
|
1011
|
+
else:
|
|
1012
|
+
# If the loop is not running, run the coroutine until complete
|
|
1013
|
+
return loop.run_until_complete(func(*args, **kwargs))
|
|
1014
|
+
except RuntimeError:
|
|
1015
|
+
# If no event loop exists, create a new one and run the coroutine
|
|
1016
|
+
return asyncio.run(func(*args, **kwargs))
|
|
1017
|
+
|
|
1018
|
+
return sync_wrapper
|
|
1019
|
+
|
|
1041
1020
|
def pauseEverythingAt(
|
|
1042
1021
|
self,
|
|
1043
1022
|
at: datetime
|
|
@@ -1073,8 +1052,8 @@ class Scheduler(ISchedule):
|
|
|
1073
1052
|
if not isinstance(at, datetime):
|
|
1074
1053
|
raise ValueError("The 'at' parameter must be a datetime object.")
|
|
1075
1054
|
|
|
1076
|
-
# Define
|
|
1077
|
-
def schedule_pause():
|
|
1055
|
+
# Define an async function to pause the scheduler
|
|
1056
|
+
async def schedule_pause():
|
|
1078
1057
|
|
|
1079
1058
|
# Only pause jobs if the scheduler is currently running
|
|
1080
1059
|
if self.isRunning():
|
|
@@ -1105,13 +1084,14 @@ class Scheduler(ISchedule):
|
|
|
1105
1084
|
self.__scheduler.pause_job(job.id)
|
|
1106
1085
|
self.__paused_by_pause_everything.add(job.id)
|
|
1107
1086
|
|
|
1108
|
-
#
|
|
1109
|
-
self.
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1087
|
+
# Execute the task callable listener
|
|
1088
|
+
self.__globalCallableListener(SchedulerPaused(EVENT_SCHEDULER_PAUSED), ListeningEvent.SCHEDULER_PAUSED)
|
|
1089
|
+
|
|
1090
|
+
# Get the current time in the configured timezone
|
|
1091
|
+
now = self.__getCurrentTime()
|
|
1092
|
+
|
|
1093
|
+
# Log an informational message indicating that the scheduler has resumed
|
|
1094
|
+
self.__logger.info(f"Orionis Scheduler resumed successfully at {now}.")
|
|
1115
1095
|
|
|
1116
1096
|
except Exception as e:
|
|
1117
1097
|
|
|
@@ -1133,7 +1113,7 @@ class Scheduler(ISchedule):
|
|
|
1133
1113
|
|
|
1134
1114
|
# Add a job to the scheduler to pause it at the specified datetime
|
|
1135
1115
|
self.__scheduler.add_job(
|
|
1136
|
-
func=schedule_pause,
|
|
1116
|
+
func=self.wrapAsyncFunction(schedule_pause), # Function to pause the scheduler
|
|
1137
1117
|
trigger=DateTrigger(run_date=at), # Trigger type is 'date' for one-time execution
|
|
1138
1118
|
id="scheduler_pause_at", # Unique job ID for pausing the scheduler
|
|
1139
1119
|
name="Pause Scheduler", # Descriptive name for the job
|
|
@@ -1183,8 +1163,8 @@ class Scheduler(ISchedule):
|
|
|
1183
1163
|
if not isinstance(at, datetime):
|
|
1184
1164
|
raise ValueError("The 'at' parameter must be a datetime object.")
|
|
1185
1165
|
|
|
1186
|
-
# Define
|
|
1187
|
-
def schedule_resume():
|
|
1166
|
+
# Define an async function to resume the scheduler
|
|
1167
|
+
async def schedule_resume():
|
|
1188
1168
|
|
|
1189
1169
|
# Only resume jobs if the scheduler is currently running
|
|
1190
1170
|
if self.isRunning():
|
|
@@ -1201,11 +1181,14 @@ class Scheduler(ISchedule):
|
|
|
1201
1181
|
self.__scheduler.resume_job(job_id)
|
|
1202
1182
|
self.__logger.info(f"User job '{job_id}' has been resumed.")
|
|
1203
1183
|
|
|
1204
|
-
#
|
|
1205
|
-
self.
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
)
|
|
1184
|
+
# Execute the task callable listener
|
|
1185
|
+
self.__globalCallableListener(SchedulerResumed(EVENT_SCHEDULER_RESUMED), ListeningEvent.SCHEDULER_RESUMED)
|
|
1186
|
+
|
|
1187
|
+
# Get the current time in the configured timezone
|
|
1188
|
+
now = self.__getCurrentTime()
|
|
1189
|
+
|
|
1190
|
+
# Log an informational message indicating that the scheduler has been paused
|
|
1191
|
+
self.__logger.info(f"Orionis Scheduler paused successfully at {now}.")
|
|
1209
1192
|
|
|
1210
1193
|
except Exception as e:
|
|
1211
1194
|
|
|
@@ -1230,7 +1213,7 @@ class Scheduler(ISchedule):
|
|
|
1230
1213
|
|
|
1231
1214
|
# Add a job to the scheduler to resume it at the specified datetime
|
|
1232
1215
|
self.__scheduler.add_job(
|
|
1233
|
-
func=schedule_resume,
|
|
1216
|
+
func=self.wrapAsyncFunction(schedule_resume), # Function to resume the scheduler
|
|
1234
1217
|
trigger=DateTrigger(run_date=at), # Trigger type is 'date' for one-time execution
|
|
1235
1218
|
id="scheduler_resume_at", # Unique job ID for resuming the scheduler
|
|
1236
1219
|
name="Resume Scheduler", # Descriptive name for the job
|
orionis/metadata/framework.py
CHANGED
|
@@ -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=gaH9YSoYDQOTTktEaFyk5OIFUQz-jtkpzQJfKHs6hf4,77213
|
|
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=TVYmpZeUzyz9k7416c1ZPMT-vPrPgTbht4x1iJwTmu4,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
|
|
@@ -417,7 +417,7 @@ orionis/test/validators/web_report.py,sha256=n9BfzOZz6aEiNTypXcwuWbFRG0OdHNSmCNu
|
|
|
417
417
|
orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnIfJYgc,1206
|
|
418
418
|
orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
419
419
|
orionis/test/view/render.py,sha256=f-zNhtKSg9R5Njqujbg2l2amAs2-mRVESneLIkWOZjU,4082
|
|
420
|
-
orionis-0.
|
|
420
|
+
orionis-0.524.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
|
|
421
421
|
tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
422
422
|
tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
423
423
|
tests/container/context/test_manager.py,sha256=wOwXpl9rHNfTTexa9GBKYMwK0_-KSQPbI-AEyGNkmAE,1356
|
|
@@ -563,8 +563,8 @@ tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
|
|
|
563
563
|
tests/testing/validators/test_testing_validators.py,sha256=WPo5GxTP6xE-Dw3X1vZoqOMpb6HhokjNSbgDsDRDvy4,16588
|
|
564
564
|
tests/testing/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
565
565
|
tests/testing/view/test_render.py,sha256=tnnMBwS0iKUIbogLvu-7Rii50G6Koddp3XT4wgdFEYM,1050
|
|
566
|
-
orionis-0.
|
|
567
|
-
orionis-0.
|
|
568
|
-
orionis-0.
|
|
569
|
-
orionis-0.
|
|
570
|
-
orionis-0.
|
|
566
|
+
orionis-0.524.0.dist-info/METADATA,sha256=YIVkp5NLpvcgxHQzPTGxREf3MOnCRs65C-f4QkJPAuI,4801
|
|
567
|
+
orionis-0.524.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
|
|
568
|
+
orionis-0.524.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
|
|
569
|
+
orionis-0.524.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
|
|
570
|
+
orionis-0.524.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|