xoscar 0.4.2__cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl → 0.4.4__cp39-cp39-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=86wcGCexxpSltidUVDP0KShGLsodQR5lck9OpOWgHIc,9042
4
- xoscar-0.4.2.dist-info/WHEEL,sha256=OyU_a3_0g4nHrDfscT3ntE6UTOgLWum2-dKsAfzpQqc,150
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
@@ -40,7 +36,7 @@ xoscar/metrics/backends/console/console_metric.py,sha256=y5CCtH33j3AqI5_Uhwi4mgO
40
36
  xoscar/metrics/backends/console/__init__.py,sha256=h_JgzSqV5lP6vQ6XX_17kE4IY4BRnvKta_7VLQAL1ms,581
41
37
  xoscar/backends/context.py,sha256=Vr_PibRxYCDQ_gYK7r-BOlw9TXw8VQbFsVTH7K7mHPk,15470
42
38
  xoscar/backends/__init__.py,sha256=VHEBQcUWM5bj027W8EUf9PiJUAP7JoMrRw3Tsvy5ySw,643
43
- xoscar/backends/core.py,sha256=GlhWdwl6gWBBwHynV4UWqOXVKDS3OMfAtOLJQHNqV-8,9294
39
+ xoscar/backends/core.py,sha256=3hWgmVYddSy341wsinYOr0yFSlICC9SBr-KQ_KeJRLw,10262
44
40
  xoscar/backends/allocate_strategy.py,sha256=tC1Nbq2tJohahUwd-zoRYHEDX65wyuX8tmeY45uWj_w,4845
45
41
  xoscar/backends/pool.py,sha256=Z7Wdab9dBF3SdQpmzgZhY0d09oTvg5gpFgzYH7vuc4w,59841
46
42
  xoscar/backends/router.py,sha256=mhSvM5KVfV882jricVcpyxAqHEvhS4zL6ivczC6fOTE,7746
@@ -77,3 +73,7 @@ xoscar/serialization/aio.py,sha256=5DySPgDxU43ec7_5Ct44-Oqt7YNSJBfuf8VdQgQlChA,4
77
73
  xoscar/serialization/numpy.py,sha256=5Kem87CvpJmzUMp3QHk4WeHU30FoQWTJJP2SwIcaQG0,2919
78
74
  xoscar/serialization/pyfury.py,sha256=sifOnVMYoS82PzZEkzkfxesmMHei23k5UAUUKUyoOYQ,1163
79
75
  xoscar/serialization/cuda.py,sha256=iFUEnN4SiquBIhyieyOrfw3TnKnW-tU_vYgqOxO_DrA,3758
76
+ xoscar-0.4.4.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
77
+ xoscar-0.4.4.dist-info/RECORD,,
78
+ xoscar-0.4.4.dist-info/METADATA,sha256=TuGS9WGtsTsESIq1SuBw9PeqUon1r14dsMrwZbJSQ-k,9042
79
+ xoscar-0.4.4.dist-info/WHEEL,sha256=OyU_a3_0g4nHrDfscT3ntE6UTOgLWum2-dKsAfzpQqc,150
File without changes