flpit 0.4.2.dev6__py3-none-any.whl → 0.4.2.dev7__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.
- flpit/task.py +19 -46
- {flpit-0.4.2.dev6.dist-info → flpit-0.4.2.dev7.dist-info}/METADATA +1 -1
- {flpit-0.4.2.dev6.dist-info → flpit-0.4.2.dev7.dist-info}/RECORD +5 -5
- {flpit-0.4.2.dev6.dist-info → flpit-0.4.2.dev7.dist-info}/WHEEL +0 -0
- {flpit-0.4.2.dev6.dist-info → flpit-0.4.2.dev7.dist-info}/licenses/LICENSE +0 -0
flpit/task.py
CHANGED
|
@@ -253,23 +253,19 @@ class _TaskMeta(type):
|
|
|
253
253
|
|
|
254
254
|
@property
|
|
255
255
|
def asyncio_interop(cls: "_TaskMeta") -> bool:
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
)
|
|
256
|
+
"""Deprecated, always True: a Task can always be awaited inside asyncio coroutines."""
|
|
257
|
+
warnings.warn(_ASYNCIO_INTEROP_DEPRECATED, DeprecationWarning, stacklevel=2)
|
|
258
|
+
return True
|
|
260
259
|
|
|
261
260
|
@asyncio_interop.setter
|
|
262
|
-
def asyncio_interop(
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
else "_await_pure_flpit_task",
|
|
271
|
-
)
|
|
272
|
-
setattr(cls, "__await__", implementation)
|
|
261
|
+
def asyncio_interop(cls: "_TaskMeta", enabled: bool) -> None:
|
|
262
|
+
warnings.warn(_ASYNCIO_INTEROP_DEPRECATED + " Setting it has no effect.", DeprecationWarning, stacklevel=2)
|
|
263
|
+
|
|
264
|
+
|
|
265
|
+
_ASYNCIO_INTEROP_DEPRECATED: Final = (
|
|
266
|
+
"Task.asyncio_interop is deprecated and will be removed in 0.5: awaiting a Task inside "
|
|
267
|
+
"asyncio coroutines always works, at no measurable cost to flpit awaits."
|
|
268
|
+
)
|
|
273
269
|
|
|
274
270
|
|
|
275
271
|
@dataclass(frozen=True)
|
|
@@ -763,9 +759,8 @@ class _WaitTask(_Operation):
|
|
|
763
759
|
|
|
764
760
|
def __repr__(self) -> str:
|
|
765
761
|
return (
|
|
766
|
-
"<flpit _WaitTask:
|
|
767
|
-
"
|
|
768
|
-
"flpit Task from asyncio>"
|
|
762
|
+
"<flpit _WaitTask: awaiting a flpit Task needs the flpit scheduler "
|
|
763
|
+
"or an asyncio event loop running on this thread>"
|
|
769
764
|
)
|
|
770
765
|
|
|
771
766
|
|
|
@@ -1791,32 +1786,13 @@ class Task(Generic[T], metaclass=_TaskMeta):
|
|
|
1791
1786
|
return self._exception
|
|
1792
1787
|
return OperationCanceledError(f"{self.name} was cancelled")
|
|
1793
1788
|
|
|
1794
|
-
def
|
|
1795
|
-
|
|
1796
|
-
error = self._error_to_raise()
|
|
1797
|
-
if error is None:
|
|
1798
|
-
return cast(T, self._result)
|
|
1799
|
-
del self # see _release_frame
|
|
1800
|
-
try:
|
|
1801
|
-
raise error
|
|
1802
|
-
finally:
|
|
1803
|
-
del error
|
|
1804
|
-
operation = _WaitTask(self._runtime, self)
|
|
1805
|
-
del self # see _release_frame
|
|
1806
|
-
try:
|
|
1807
|
-
return (yield operation)
|
|
1808
|
-
finally:
|
|
1809
|
-
del operation
|
|
1810
|
-
|
|
1811
|
-
__await__ = _await_pure_flpit_task
|
|
1812
|
-
|
|
1813
|
-
def _await_asyncio_interop(self) -> Generator[Any, T, T]:
|
|
1814
|
-
"""``__await__`` that also works inside asyncio coroutines (``Task.asyncio_interop``).
|
|
1789
|
+
def __await__(self) -> Generator[Any, T, T]:
|
|
1790
|
+
"""Await the task from flpit code or from an asyncio coroutine.
|
|
1815
1791
|
|
|
1816
|
-
Awaited by flpit,
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1792
|
+
Awaited by flpit, a pending task asks one question: is an asyncio loop running on this
|
|
1793
|
+
thread? That is one C call (asyncio's ``_get_running_loop``, which returns None instead of
|
|
1794
|
+
raising), or a dict lookup while asyncio isn't imported at all (see _asyncio_running_loop);
|
|
1795
|
+
about 15 ns, within measurement noise of an await.
|
|
1820
1796
|
|
|
1821
1797
|
Inside asyncio, the task's completion resolves an asyncio future on that loop. Neither the
|
|
1822
1798
|
frame nor the callbacks keep the task (see _release_frame): a failed task awaited from
|
|
@@ -1851,9 +1827,6 @@ class Task(Generic[T], metaclass=_TaskMeta):
|
|
|
1851
1827
|
finally:
|
|
1852
1828
|
del future
|
|
1853
1829
|
|
|
1854
|
-
# On by default: awaited by flpit code it costs about 0.1 µs (see _await_asyncio_interop).
|
|
1855
|
-
__await__ = _await_asyncio_interop
|
|
1856
|
-
|
|
1857
1830
|
def _error_to_raise(self) -> BaseException | None:
|
|
1858
1831
|
"""The exception that awaiting this completed task raises; None if it succeeded.
|
|
1859
1832
|
|
|
@@ -5,7 +5,7 @@ flpit/concurrent.py,sha256=HZueI_zSTX9ozwmxwrn7_HSrxT4VL3CKoDbKQRqAKLA,32211
|
|
|
5
5
|
flpit/csv.py,sha256=QMG8AxYR32i4I_lD1KL284OXdScN6vjjgusvnqw2q-A,25862
|
|
6
6
|
flpit/flp.py,sha256=WaZnrtYdxwEOJUEBv_hXg8Uwm81h8kcH64pjDh8oJhU,1527
|
|
7
7
|
flpit/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
8
|
-
flpit/task.py,sha256=
|
|
8
|
+
flpit/task.py,sha256=REvC_OWFrtJLsn6VqXmTPOZooVP5wiiw62_TCjoiBlw,168041
|
|
9
9
|
flpit/threading.py,sha256=MeWwOI2DSejmwiivSL1IVGx0US-FEsgcNRjFWdwdcSg,37236
|
|
10
10
|
flpit/core/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
flpit/core/_grouping.py,sha256=QZNdNqXx4fcRsnun4nwkGKnst63Y10Q-rYBevof7Abw,954
|
|
@@ -20,7 +20,7 @@ flpit/json/__init__.py,sha256=7U7-KaxLbQybqmNTqDf4U54Njhac2ep5gxPEaavR7hA,4625
|
|
|
20
20
|
flpit/json/_core.py,sha256=IhLM116xW4jI4gg3-QmRGptVr5pHRY7X7aicm8TmO3Y,13445
|
|
21
21
|
flpit/json/_msgspec.py,sha256=19NB98R1tftz8LYY_2QriWo9d4Syii4f7QW_s8vWL2s,20124
|
|
22
22
|
flpit/json/_native.py,sha256=E_Ro3rXTCKDpb6jicBOYU9fzOJch6ZJkLqsKJNXAsTg,39974
|
|
23
|
-
flpit-0.4.2.
|
|
24
|
-
flpit-0.4.2.
|
|
25
|
-
flpit-0.4.2.
|
|
26
|
-
flpit-0.4.2.
|
|
23
|
+
flpit-0.4.2.dev7.dist-info/METADATA,sha256=QDp_Lc5rZXJQneHiFMmfceGtv6t4EaRndKJLSJPlfpQ,19395
|
|
24
|
+
flpit-0.4.2.dev7.dist-info/WHEEL,sha256=2iZrJkDIkeDh0k9SikKMqFuRP-ua6mb4Ir1AsER4BEw,87
|
|
25
|
+
flpit-0.4.2.dev7.dist-info/licenses/LICENSE,sha256=bi5Vg_YP3Oq3jaOMQT4b7WZu0NfBcZr-nRyOExUKJrQ,1063
|
|
26
|
+
flpit-0.4.2.dev7.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|