xoscar 0.7.0__cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl → 0.7.1__cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.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.

Potentially problematic release.


This version of xoscar might be problematic. Click here for more details.

xoscar/__init__.py CHANGED
@@ -33,6 +33,7 @@ from .api import (
33
33
  wait_actor_pool_recovered,
34
34
  get_pool_config,
35
35
  generator,
36
+ wait_for,
36
37
  )
37
38
  from .backends import allocate_strategy
38
39
  from .backends.pool import MainActorPoolType
xoscar/api.py CHANGED
@@ -26,6 +26,7 @@ from numbers import Number
26
26
  from typing import (
27
27
  TYPE_CHECKING,
28
28
  Any,
29
+ Awaitable,
29
30
  Dict,
30
31
  Generic,
31
32
  List,
@@ -181,6 +182,39 @@ async def create_actor_pool(
181
182
  )
182
183
 
183
184
 
185
+ async def wait_for(fut: Awaitable[Any], timeout: int | float | None = None) -> Any:
186
+ # asyncio.wait_for() on Xoscar actor call cannot work as expected,
187
+ # because when time out, the future will be cancelled, but an actor call will catch this error,
188
+ # and send a CancelMessage to the dest pool, if the CancelMessage cannot be processed correctly(e.g. the dest pool hangs),
189
+ # the time out will never happen. Thus this PR added a new API so that no matter the CancelMessage delivered or not,
190
+ # the timeout will happen as expected.
191
+ loop = asyncio.get_running_loop()
192
+ new_fut = loop.create_future()
193
+ task = asyncio.ensure_future(fut)
194
+
195
+ def on_done(f: asyncio.Future):
196
+ if new_fut.done():
197
+ return
198
+ if f.cancelled():
199
+ new_fut.cancel()
200
+ elif f.exception():
201
+ new_fut.set_exception(f.exception()) # type: ignore
202
+ else:
203
+ new_fut.set_result(f.result())
204
+
205
+ task.add_done_callback(on_done)
206
+
207
+ try:
208
+ return await asyncio.wait_for(new_fut, timeout)
209
+ except asyncio.TimeoutError:
210
+ if not task.done():
211
+ try:
212
+ task.cancel() # Try to cancel without waiting
213
+ except Exception:
214
+ logger.warning("Failed to cancel task", exc_info=True)
215
+ raise
216
+
217
+
184
218
  def buffer_ref(address: str, buffer: Any) -> BufferRef:
185
219
  """
186
220
  Init buffer ref according address and buffer.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xoscar
3
- Version: 0.7.0
3
+ Version: 0.7.1
4
4
  Summary: Python actor framework for heterogeneous computing.
5
5
  Home-page: http://github.com/xorbitsai/xoscar
6
6
  Author: Qin Xuye
@@ -1,9 +1,9 @@
1
- xoscar/__init__.py,sha256=0zX8kKaio3ZIrlzB79WybcravMJw1OxPWjDspTgJFyQ,1608
1
+ xoscar/__init__.py,sha256=sy7Wtn2EuQZI0I4Az_MfsBVZm4G0DRj46qRyExgmnJk,1622
2
2
  xoscar/_utils.cpython-311-aarch64-linux-gnu.so,sha256=fjayJQYIcmSLRfyUO5MaKepbLaIPifcA-QImEdH1IDU,1209432
3
3
  xoscar/_utils.pxd,sha256=5KYAL3jfPdejsHnrGGT2s--ZUX5SXznQWpHVSno429k,1157
4
4
  xoscar/_utils.pyx,sha256=frgVQ5xGp92jBKc4PsPmjOlVsXlKeHWtTOAMfHmBaII,7380
5
5
  xoscar/_version.py,sha256=ClSPrUjgGRGHIkVMQV9XQnkQ-n0akJMnq_rh819nqFE,23719
6
- xoscar/api.py,sha256=3hztPoOxg8A_mlhWyWgVP7FMXG0PATA1TP4Rbaj7A-g,13327
6
+ xoscar/api.py,sha256=zxNqOjGiTIKuAip9WJ0LOoM7yevD6P5rb-sLynpZ2Zo,14648
7
7
  xoscar/backend.py,sha256=is436OPkZfSpQXaoqTRVta5eoye_pp45RFgCstAk2hU,1850
8
8
  xoscar/batch.py,sha256=DpArS0L3WYJ_HVPG-6hSYEwoAFY1mY2-mlC4Jp5M_Dw,7872
9
9
  xoscar/constants.py,sha256=QHHSREw6uWBBjQDCFqlNfTvBZgniJPGy42KSIsR8Fqw,787
@@ -80,7 +80,7 @@ xoscar/serialization/scipy.py,sha256=yOEi0NB8cqQ6e2UnCZ1w006RsB7T725tIL-DM_hNcsU
80
80
  xoscar/virtualenv/__init__.py,sha256=65t9_X1DvbanNjFy366SiiWZrRTpa9SXWMXPmqayE-4,1117
81
81
  xoscar/virtualenv/core.py,sha256=Ld5bSkKp8ywekGuUq61uyms5I8Hm1WdbkbLxmCw-ML0,1342
82
82
  xoscar/virtualenv/uv.py,sha256=rVurn1PKlvR22Bm_F1uouIb1eMkB_wr-_29dBvMl7bo,3182
83
- xoscar-0.7.0.dist-info/METADATA,sha256=beSTIQsGUSOi5z0cGWQdavB4uSrNCcCtZxrpaZ0IMC8,9134
84
- xoscar-0.7.0.dist-info/WHEEL,sha256=SqeGUsDS88JbDMFEmg5kozXLxkaYruG6PG7xezonLcQ,154
85
- xoscar-0.7.0.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
86
- xoscar-0.7.0.dist-info/RECORD,,
83
+ xoscar-0.7.1.dist-info/METADATA,sha256=GNHx0SyIciNz1W7kBgcn5Dwti9Xak-p353ybGr52avQ,9134
84
+ xoscar-0.7.1.dist-info/WHEEL,sha256=SqeGUsDS88JbDMFEmg5kozXLxkaYruG6PG7xezonLcQ,154
85
+ xoscar-0.7.1.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
86
+ xoscar-0.7.1.dist-info/RECORD,,
File without changes