oceanprotocol-job-details 0.3.11__py3-none-any.whl → 0.3.12__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.
@@ -1,13 +1,24 @@
1
1
  import asyncio
2
- from typing import Coroutine, TypeVar
2
+ import inspect
3
+ from typing import Any, Callable, Coroutine, TypeVar
3
4
 
4
5
  T = TypeVar("T")
5
6
 
6
7
 
7
- def run_in_executor(coro: Coroutine[None, None, T]) -> T:
8
+ def run_in_executor(obj: Callable[..., Any] | Coroutine[Any, Any, T]) -> T:
9
+ if callable(obj) and not inspect.iscoroutinefunction(obj):
10
+ return obj()
11
+
12
+ if inspect.iscoroutinefunction(obj):
13
+ obj = obj()
14
+
15
+ if not inspect.iscoroutine(obj):
16
+ return obj
17
+
8
18
  try:
9
19
  loop = asyncio.get_running_loop()
10
20
  except RuntimeError:
11
- return asyncio.run(coro)
12
- else:
13
- return loop.run_until_complete(coro)
21
+ return asyncio.run(obj)
22
+
23
+ future = asyncio.run_coroutine_threadsafe(obj, loop)
24
+ return future.result()
@@ -9,7 +9,7 @@ import aiofiles
9
9
  from pydantic import BaseModel, ConfigDict, Secret
10
10
 
11
11
  from oceanprotocol_job_details.domain import DDO, Files, Paths
12
- from oceanprotocol_job_details.executers import run_in_executor
12
+ from oceanprotocol_job_details.executors import run_in_executor
13
13
 
14
14
  InputParametersT = TypeVar("InputParametersT", BaseModel, None)
15
15
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: oceanprotocol-job-details
3
- Version: 0.3.11
3
+ Version: 0.3.12
4
4
  Summary: A Python package to get details from OceanProtocol jobs
5
5
  Project-URL: Homepage, https://github.com/AgrospAI/oceanprotocol-job-details
6
6
  Project-URL: Issues, https://github.com/AgrospAI/oceanprotocol-job-details/issues
@@ -1,9 +1,9 @@
1
1
  oceanprotocol_job_details/__init__.py,sha256=sq_C8Ey4_4oHiX9cO1wne7ZsWqs86WWgHfKQ5PMwwak,218
2
2
  oceanprotocol_job_details/di.py,sha256=H4_n9NrNuRB2s9uarSkwDYzjD1i7sV8dySRfHt21QWM,1316
3
3
  oceanprotocol_job_details/domain.py,sha256=ifw-hKFAJj0Gl_wJuH-51LQx4KPsCyEVDsT10xg9uBw,3842
4
- oceanprotocol_job_details/executors.py,sha256=vb2fpbtP295axNbWBmlbSyULJtbM6XgL_kMRDO_A8ms,295
4
+ oceanprotocol_job_details/executors.py,sha256=v7VjtAW8yawk9mF1TgU3fF73JBk4l9UasP7egfn7xhc,576
5
5
  oceanprotocol_job_details/helpers.py,sha256=ABm3oIRwPd-4XeCOIszCbfL2wkUJqVJJ2bqy3hR4jyw,1064
6
- oceanprotocol_job_details/ocean.py,sha256=77ucvfhhHr4tGDOxUuBdArVmokx6sitMxddaAThjRDA,1514
6
+ oceanprotocol_job_details/ocean.py,sha256=ybpBqMKKqnB2Oyc2XNeay5EpdH041w9fH1chM8hrHxY,1514
7
7
  oceanprotocol_job_details/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
8
8
  oceanprotocol_job_details/settings.py,sha256=o_1Hn2vl5hMk7bAkdS7GjE4nKOAyHm7dScO2_o2sPuY,1345
9
9
  oceanprotocol_job_details/loaders/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -12,7 +12,7 @@ oceanprotocol_job_details/loaders/impl/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JC
12
12
  oceanprotocol_job_details/loaders/impl/ddo.py,sha256=XthrQFhmP85XSVzVjBlLePtTowGR3BAsmVp3jngiQ08,668
13
13
  oceanprotocol_job_details/loaders/impl/files.py,sha256=Y2vFBT2T9w9zrdpmf550-LQJxwtNPUGa0UU6bBzk9AU,1145
14
14
  oceanprotocol_job_details/loaders/impl/job_details.py,sha256=QwlUaG9KozkI1wX66oDTPg4TjGkvSsi8O-TctF6eWvo,724
15
- oceanprotocol_job_details-0.3.11.dist-info/METADATA,sha256=1677Afid-h4xuWBs_uUgM4mVzrL4rlOI1bVw5FSXfhQ,4495
16
- oceanprotocol_job_details-0.3.11.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
- oceanprotocol_job_details-0.3.11.dist-info/licenses/LICENSE,sha256=ni3ix7P_GxK1W3VGC4fJ3o6QoCngCEpSuTJwO4nkpbw,1055
18
- oceanprotocol_job_details-0.3.11.dist-info/RECORD,,
15
+ oceanprotocol_job_details-0.3.12.dist-info/METADATA,sha256=9XXhPa3sGMWiSFHOqayYU7xd4su_otGnaCrtjYfZWb8,4495
16
+ oceanprotocol_job_details-0.3.12.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
17
+ oceanprotocol_job_details-0.3.12.dist-info/licenses/LICENSE,sha256=ni3ix7P_GxK1W3VGC4fJ3o6QoCngCEpSuTJwO4nkpbw,1055
18
+ oceanprotocol_job_details-0.3.12.dist-info/RECORD,,