xoscar 0.4.2__cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl → 0.4.4__cp312-cp312-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/backends/core.py CHANGED
@@ -16,6 +16,7 @@
16
16
  from __future__ import annotations
17
17
 
18
18
  import asyncio
19
+ import atexit
19
20
  import copy
20
21
  import logging
21
22
  import threading
@@ -207,6 +208,40 @@ class ActorCallerThreadLocal:
207
208
  _ = [task.cancel() for task in self._clients.values()]
208
209
 
209
210
 
211
+ def _cancel_all_tasks(loop):
212
+ to_cancel = asyncio.all_tasks(loop)
213
+ if not to_cancel:
214
+ return
215
+
216
+ for task in to_cancel:
217
+ task.cancel()
218
+
219
+ loop.run_until_complete(asyncio.gather(*to_cancel, return_exceptions=True))
220
+
221
+ for task in to_cancel:
222
+ if task.cancelled():
223
+ continue
224
+ if task.exception() is not None:
225
+ loop.call_exception_handler(
226
+ {
227
+ "message": "unhandled exception during asyncio.run() shutdown",
228
+ "exception": task.exception(),
229
+ "task": task,
230
+ }
231
+ )
232
+
233
+
234
+ def _safe_run_forever(loop):
235
+ loop.run_forever()
236
+ _cancel_all_tasks(loop)
237
+
238
+
239
+ def _safe_exit_thread(loop, thread):
240
+ # To avoid _enter_buffered_busy: could not acquire lock
241
+ loop.call_soon_threadsafe(loop.stop)
242
+ thread.join()
243
+
244
+
210
245
  class ActorCaller:
211
246
  __slots__ = "_thread_local"
212
247
 
@@ -214,8 +249,11 @@ class ActorCaller:
214
249
  pass
215
250
 
216
251
  _close_loop = asyncio.new_event_loop()
217
- _close_thread = threading.Thread(target=_close_loop.run_forever, daemon=True)
252
+ _close_thread = threading.Thread(
253
+ target=_safe_run_forever, args=(_close_loop,), daemon=True
254
+ )
218
255
  _close_thread.start()
256
+ atexit.register(_safe_exit_thread, _close_loop, _close_thread)
219
257
 
220
258
  def __init__(self):
221
259
  self._thread_local = threading.local()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xoscar
3
- Version: 0.4.2
3
+ Version: 0.4.4
4
4
  Summary: Python actor framework for heterogeneous computing.
5
5
  Home-page: http://github.com/xorbitsai/xoscar
6
6
  Author: Qin Xuye
@@ -1,7 +1,3 @@
1
- xoscar-0.4.2.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
2
- xoscar-0.4.2.dist-info/RECORD,,
3
- xoscar-0.4.2.dist-info/METADATA,sha256=1FxP6MBE6AUhm_NMzJJ4pHuf5my1CDqHnSYJ5QFVm2Q,9042
4
- xoscar-0.4.2.dist-info/WHEEL,sha256=sLizzaCm5RO_U5e_F5zOShQNJ3TeuZ7GEwyo10nwIfE,153
5
1
  xoscar/errors.py,sha256=wBlQOKsXf0Fc4skN39tDie0YZT-VIAuLNRgoDl2pZcA,1241
6
2
  xoscar/nvutils.py,sha256=qmW4mKLU0WB2yCs198ccQOgLL02zB7Fsa-AotO3NOmg,20412
7
3
  xoscar/utils.py,sha256=jUw6OICZUPBbmS1b3GE4vLctJf6fCKXrYtLtBuK-Oqc,16483
@@ -42,7 +38,7 @@ xoscar/metrics/backends/console/__init__.py,sha256=h_JgzSqV5lP6vQ6XX_17kE4IY4BRn
42
38
  xoscar/backends/message.cpython-312-aarch64-linux-gnu.so,sha256=PKUmScWty4eTytL1G8YV2F54xTpeiBqTtkpwY75bHz0,3488072
43
39
  xoscar/backends/context.py,sha256=Vr_PibRxYCDQ_gYK7r-BOlw9TXw8VQbFsVTH7K7mHPk,15470
44
40
  xoscar/backends/__init__.py,sha256=VHEBQcUWM5bj027W8EUf9PiJUAP7JoMrRw3Tsvy5ySw,643
45
- xoscar/backends/core.py,sha256=GlhWdwl6gWBBwHynV4UWqOXVKDS3OMfAtOLJQHNqV-8,9294
41
+ xoscar/backends/core.py,sha256=3hWgmVYddSy341wsinYOr0yFSlICC9SBr-KQ_KeJRLw,10262
46
42
  xoscar/backends/allocate_strategy.py,sha256=tC1Nbq2tJohahUwd-zoRYHEDX65wyuX8tmeY45uWj_w,4845
47
43
  xoscar/backends/pool.py,sha256=Z7Wdab9dBF3SdQpmzgZhY0d09oTvg5gpFgzYH7vuc4w,59841
48
44
  xoscar/backends/router.py,sha256=mhSvM5KVfV882jricVcpyxAqHEvhS4zL6ivczC6fOTE,7746
@@ -80,3 +76,7 @@ xoscar/serialization/numpy.py,sha256=5Kem87CvpJmzUMp3QHk4WeHU30FoQWTJJP2SwIcaQG0
80
76
  xoscar/serialization/pyfury.py,sha256=sifOnVMYoS82PzZEkzkfxesmMHei23k5UAUUKUyoOYQ,1163
81
77
  xoscar/serialization/core.cpython-312-aarch64-linux-gnu.so,sha256=7troSFzh2ajnwlFW504vukrKU0XLxJzcAdDMYav6EN0,3369360
82
78
  xoscar/serialization/cuda.py,sha256=iFUEnN4SiquBIhyieyOrfw3TnKnW-tU_vYgqOxO_DrA,3758
79
+ xoscar-0.4.4.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
80
+ xoscar-0.4.4.dist-info/RECORD,,
81
+ xoscar-0.4.4.dist-info/METADATA,sha256=8sNSbbwMLWNK_U4dPToYPbX3J3epO77vL9ivudhzOBY,9042
82
+ xoscar-0.4.4.dist-info/WHEEL,sha256=sLizzaCm5RO_U5e_F5zOShQNJ3TeuZ7GEwyo10nwIfE,153
File without changes