orionis 0.534.0__py3-none-any.whl → 0.535.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.
@@ -24,6 +24,7 @@ from orionis.foundation.config.testing.entities.testing import Testing
24
24
  from orionis.foundation.contracts.application import IApplication
25
25
  from orionis.foundation.exceptions import OrionisTypeError, OrionisRuntimeError, OrionisValueError
26
26
  from orionis.foundation.providers.logger_provider import LoggerProvider
27
+ from orionis.services.asynchrony.coroutines import Coroutine
27
28
  from orionis.services.log.contracts.log_service import ILogger
28
29
 
29
30
  class Application(Container, IApplication):
@@ -342,7 +343,7 @@ class Application(Container, IApplication):
342
343
  # Register the provider in the container
343
344
  # Check if register is a coroutine function
344
345
  if asyncio.iscoroutinefunction(class_provider.register):
345
- asyncio.run(class_provider.register())
346
+ Coroutine(class_provider.register).run()
346
347
  else:
347
348
  class_provider.register()
348
349
 
@@ -379,7 +380,7 @@ class Application(Container, IApplication):
379
380
  if hasattr(provider, 'boot') and callable(getattr(provider, 'boot')):
380
381
  # Check if boot is a coroutine function
381
382
  if asyncio.iscoroutinefunction(provider.boot):
382
- asyncio.run(provider.boot())
383
+ Coroutine(provider.boot).run()
383
384
  else:
384
385
  provider.boot()
385
386
 
@@ -5,7 +5,7 @@
5
5
  NAME = "orionis"
6
6
 
7
7
  # Current version of the framework
8
- VERSION = "0.534.0"
8
+ VERSION = "0.535.0"
9
9
 
10
10
  # Full name of the author or maintainer of the project
11
11
  AUTHOR = "Raul Mauricio Uñate Castro"
@@ -6,23 +6,71 @@ T = TypeVar("T")
6
6
 
7
7
  class ICoroutine(ABC):
8
8
 
9
+ @abstractmethod
10
+ def invoke(self, *args, **kwargs) -> Union[T, asyncio.Task, None]:
11
+ """
12
+ Invoke the callable coroutine function with the provided arguments.
13
+
14
+ This method executes a callable coroutine function or regular function with the given
15
+ arguments and keyword arguments. It automatically detects the execution context and
16
+ handles both synchronous and asynchronous execution appropriately.
17
+
18
+ Parameters
19
+ ----------
20
+ *args : tuple
21
+ Positional arguments to pass to the callable function.
22
+ **kwargs : dict
23
+ Keyword arguments to pass to the callable function.
24
+
25
+ Returns
26
+ -------
27
+ Union[T, asyncio.Task, None]
28
+ - T: The result of the coroutine if executed synchronously
29
+ - asyncio.Task: A task object if scheduled for asynchronous execution
30
+ - None: If the callable is not a coroutine function
31
+
32
+ Raises
33
+ ------
34
+ OrionisCoroutineException
35
+ If an error occurs during coroutine execution.
36
+ RuntimeError
37
+ If an error occurs during callable execution that is not coroutine-related.
38
+
39
+ Notes
40
+ -----
41
+ - Only callable objects can be invoked with this method
42
+ - For coroutine functions, execution context is automatically detected
43
+ - Non-coroutine callables are executed directly and return None
44
+ - Exceptions are wrapped with appropriate context information
45
+
46
+ Examples
47
+ --------
48
+ >>> async def my_coro(x, y):
49
+ ... return x + y
50
+ >>> coro = Coroutine(my_coro)
51
+ >>> result = coro.invoke(1, 2) # Returns Task or result depending on context
52
+ """
53
+ pass
54
+
9
55
  @abstractmethod
10
56
  def run(self) -> Union[T, asyncio.Future]:
11
57
  """
12
- Execute the wrapped coroutine either synchronously or asynchronously, depending on the execution context.
58
+ Executes the wrapped coroutine, adapting to the current event loop context.
13
59
 
14
60
  Returns
15
61
  -------
16
62
  T or asyncio.Future
17
- If called outside of an event loop, returns the result of the coroutine execution (type T).
18
- If called within an event loop, returns an asyncio.Future representing the scheduled coroutine.
63
+ The result of the coroutine if executed synchronously, or an asyncio.Future if scheduled asynchronously.
64
+
65
+ Raises
66
+ ------
67
+ RuntimeError
68
+ If the coroutine cannot be executed due to event loop issues.
19
69
 
20
70
  Notes
21
71
  -----
22
- - Executes the coroutine synchronously and returns its result when called outside an event loop.
23
- - Schedules the coroutine for asynchronous execution and returns a Future when called inside an event loop.
24
- - The caller is responsible for awaiting the Future if asynchronous execution is used.
72
+ - If called outside an active event loop, the coroutine is executed synchronously and its result is returned.
73
+ - If called within an active event loop, the coroutine is scheduled for asynchronous execution and a Future is returned.
74
+ - The method automatically detects the execution context and chooses the appropriate execution strategy.
25
75
  """
26
-
27
- # This method should be implemented by subclasses to handle coroutine execution.
28
- pass
76
+ pass
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: orionis
3
- Version: 0.534.0
3
+ Version: 0.535.0
4
4
  Summary: Orionis Framework – Elegant, Fast, and Powerful.
5
5
  Home-page: https://github.com/orionis-framework/framework
6
6
  Author: Raul Mauricio Uñate Castro
@@ -126,7 +126,7 @@ orionis/failure/contracts/handler.py,sha256=drNE8iu8RUHi3TgKn-lUEIfVsZeGsMTUecTZ
126
126
  orionis/failure/entities/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
127
127
  orionis/failure/entities/throwable.py,sha256=ogys062uhim5QMYU62ezlnumRAnYQlUf_vZvQY47S3U,1227
128
128
  orionis/foundation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
129
- orionis/foundation/application.py,sha256=JtTFU__67Vrg4vDA5ieNu1WgqiBjulaJJRjAgYIVRgE,86422
129
+ orionis/foundation/application.py,sha256=RwMRjRp9kkKRbDsz_lAN4NYadCuaDbmDnccWKl8aKng,86488
130
130
  orionis/foundation/config/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
131
131
  orionis/foundation/config/startup.py,sha256=vbzduprRCNyYeR2nnMaqc1uKXw6PTzAY2jVfXNQKN8I,9691
132
132
  orionis/foundation/config/app/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -242,13 +242,13 @@ orionis/foundation/providers/scheduler_provider.py,sha256=1do4B09bU_6xbFHHVYYTGM
242
242
  orionis/foundation/providers/testing_provider.py,sha256=SrJRpdvcblx9WvX7x9Y3zc7OQfiTf7la0HAJrm2ESlE,3725
243
243
  orionis/foundation/providers/workers_provider.py,sha256=oa_2NIDH6UxZrtuGkkoo_zEoNIMGgJ46vg5CCgAm7wI,3926
244
244
  orionis/metadata/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
245
- orionis/metadata/framework.py,sha256=nuA2nefeGQ2B3VGS-om5qZigBmEBbAZwhTnm54CFJn0,4109
245
+ orionis/metadata/framework.py,sha256=uWTlWqt2g9tvRAk56GneEvJAcpVopbXX5L67RJzuXX8,4109
246
246
  orionis/metadata/package.py,sha256=k7Yriyp5aUcR-iR8SK2ec_lf0_Cyc-C7JczgXa-I67w,16039
247
247
  orionis/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
248
248
  orionis/services/asynchrony/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
249
249
  orionis/services/asynchrony/coroutines.py,sha256=M1o4Al5dk8BR85CWHHUgymVQaD_6PgirenQMeITUoZQ,6863
250
250
  orionis/services/asynchrony/contracts/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
251
- orionis/services/asynchrony/contracts/coroutines.py,sha256=rVy1HO58RFKliGeaf6GUC7mGtPZXimIhzkFHR1EWRoc,1082
251
+ orionis/services/asynchrony/contracts/coroutines.py,sha256=Hjm-JOK-CjCDWa8sSaJZ7ccM_LxsVsYWFcYSSVciQ3U,2825
252
252
  orionis/services/asynchrony/exceptions/__init__.py,sha256=COm6RhSiuwWqy3YcJ_0gVu6XHjn5P3zVaiUp5Pw_h48,99
253
253
  orionis/services/asynchrony/exceptions/exception.py,sha256=Npze-29hlzjXxOZt3RF1R9yp0O1tMSRt7sCWXKjy3Pc,772
254
254
  orionis/services/environment/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -420,7 +420,7 @@ orionis/test/validators/web_report.py,sha256=n9BfzOZz6aEiNTypXcwuWbFRG0OdHNSmCNu
420
420
  orionis/test/validators/workers.py,sha256=rWcdRexINNEmGaO7mnc1MKUxkHKxrTsVuHgbnIfJYgc,1206
421
421
  orionis/test/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
422
422
  orionis/test/view/render.py,sha256=f-zNhtKSg9R5Njqujbg2l2amAs2-mRVESneLIkWOZjU,4082
423
- orionis-0.534.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
423
+ orionis-0.535.0.dist-info/licenses/LICENCE,sha256=JhC-z_9mbpUrCfPjcl3DhDA8trNDMzb57cvRSam1avc,1463
424
424
  tests/container/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
425
425
  tests/container/context/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
426
426
  tests/container/context/test_manager.py,sha256=wOwXpl9rHNfTTexa9GBKYMwK0_-KSQPbI-AEyGNkmAE,1356
@@ -566,8 +566,8 @@ tests/testing/validators/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZ
566
566
  tests/testing/validators/test_testing_validators.py,sha256=WPo5GxTP6xE-Dw3X1vZoqOMpb6HhokjNSbgDsDRDvy4,16588
567
567
  tests/testing/view/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
568
568
  tests/testing/view/test_render.py,sha256=tnnMBwS0iKUIbogLvu-7Rii50G6Koddp3XT4wgdFEYM,1050
569
- orionis-0.534.0.dist-info/METADATA,sha256=R7FBw3jg3tfT8gujp8PmJLFqoTJK6oXImdwynE9zV9c,4801
570
- orionis-0.534.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
571
- orionis-0.534.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
572
- orionis-0.534.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
573
- orionis-0.534.0.dist-info/RECORD,,
569
+ orionis-0.535.0.dist-info/METADATA,sha256=fgBBQFe8aw1uvm0D0Wr1yobSyOoPlEzaiEaylQpTSd0,4801
570
+ orionis-0.535.0.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
571
+ orionis-0.535.0.dist-info/top_level.txt,sha256=2bdoHgyGZhOtLAXS6Om8OCTmL24dUMC_L1quMe_ETbk,14
572
+ orionis-0.535.0.dist-info/zip-safe,sha256=frcCV1k9oG9oKj3dpUqdJg1PxRT2RSN_XKdLCPjaYaY,2
573
+ orionis-0.535.0.dist-info/RECORD,,