xoscar 0.4.4__cp310-cp310-macosx_11_0_arm64.whl → 0.4.6__cp310-cp310-macosx_11_0_arm64.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.

Binary file
@@ -249,12 +249,5 @@ class DummyClient(Client):
249
249
  async def close(self):
250
250
  await super().close()
251
251
  if self._task is not None:
252
- task_loop = self._task.get_loop()
253
- if task_loop is not None:
254
- if not task_loop.is_running():
255
- logger.warning(
256
- "Dummy channel cancel task on a stopped loop, dest address: %s.",
257
- self.dest_address,
258
- )
259
252
  self._task.cancel()
260
253
  self._task = None
@@ -34,6 +34,7 @@ from ...serialization import AioDeserializer, AioSerializer, deserialize
34
34
  from ...utils import classproperty, implements, is_py_312, is_v6_ip
35
35
  from .base import Channel, ChannelType, Client, Server
36
36
  from .core import register_client, register_server
37
+ from .errors import ChannelClosed
37
38
  from .utils import read_buffers, write_buffers
38
39
 
39
40
  _is_windows: bool = sys.platform.startswith("win")
@@ -80,12 +81,19 @@ class SocketChannel(Channel):
80
81
  serializer = AioSerializer(message, compress=compress)
81
82
  buffers = await serializer.run()
82
83
 
83
- # write buffers
84
- write_buffers(self.writer, buffers)
85
- async with self._send_lock:
86
- # add lock, or when parallel send,
87
- # assertion error may be raised
88
- await self.writer.drain()
84
+ try:
85
+ # write buffers
86
+ write_buffers(self.writer, buffers)
87
+ async with self._send_lock:
88
+ # add lock, or when parallel send,
89
+ # assertion error may be raised
90
+ await self.writer.drain()
91
+ except RuntimeError as e:
92
+ if self.writer.is_closing():
93
+ raise ChannelClosed(
94
+ "Channel already closed, cannot write message"
95
+ ) from e
96
+ raise e
89
97
 
90
98
  @implements(Channel.recv)
91
99
  async def recv(self):
xoscar/backends/core.py CHANGED
@@ -196,12 +196,14 @@ class ActorCallerThreadLocal:
196
196
  return await self.call_with_client(client, message, wait)
197
197
 
198
198
  async def stop(self):
199
- logger.debug("Actor caller stop.")
200
199
  try:
201
200
  await asyncio.gather(*[client.close() for client in self._clients])
202
201
  except (ConnectionError, ServerClosed):
203
202
  pass
204
- self.cancel_tasks()
203
+ try:
204
+ self.cancel_tasks()
205
+ except:
206
+ pass
205
207
 
206
208
  def cancel_tasks(self):
207
209
  # cancel listening for all clients
@@ -232,14 +234,11 @@ def _cancel_all_tasks(loop):
232
234
 
233
235
 
234
236
  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()
237
+ try:
238
+ loop.run_forever()
239
+ finally:
240
+ _cancel_all_tasks(loop)
241
+ loop.stop()
243
242
 
244
243
 
245
244
  class ActorCaller:
@@ -253,7 +252,7 @@ class ActorCaller:
253
252
  target=_safe_run_forever, args=(_close_loop,), daemon=True
254
253
  )
255
254
  _close_thread.start()
256
- atexit.register(_safe_exit_thread, _close_loop, _close_thread)
255
+ atexit.register(_close_loop.call_soon_threadsafe, _close_loop.stop)
257
256
 
258
257
  def __init__(self):
259
258
  self._thread_local = threading.local()
@@ -16,6 +16,7 @@
16
16
  from __future__ import annotations
17
17
 
18
18
  import asyncio
19
+ import atexit
19
20
  import concurrent.futures as futures
20
21
  import configparser
21
22
  import contextlib
@@ -29,6 +30,7 @@ import sys
29
30
  import threading
30
31
  import uuid
31
32
  from dataclasses import dataclass
33
+ from multiprocessing import util
32
34
  from types import TracebackType
33
35
  from typing import List, Optional
34
36
 
@@ -79,6 +81,19 @@ logger = logging.getLogger(__name__)
79
81
  _init_main_suspended_local = threading.local()
80
82
 
81
83
 
84
+ def _terminate_children():
85
+ for c in multiprocessing.active_children():
86
+ try:
87
+ c.terminate()
88
+ except Exception:
89
+ pass
90
+
91
+
92
+ if util:
93
+ # Import multiprocessing.util to register _exit_function at exit.
94
+ atexit.register(_terminate_children)
95
+
96
+
82
97
  def _patch_spawn_get_preparation_data():
83
98
  try:
84
99
  from multiprocessing import spawn as mp_spawn
@@ -309,6 +324,7 @@ class MainActorPool(MainActorPoolBase):
309
324
  raise
310
325
  finally:
311
326
  status_queue.put(process_status)
327
+ status_queue.cancel_join_thread()
312
328
  await pool.join()
313
329
 
314
330
  async def append_sub_pool(
xoscar/backends/pool.py CHANGED
@@ -377,7 +377,7 @@ class AbstractActorPool(ABC):
377
377
  try:
378
378
  await channel.send(result)
379
379
  except (ChannelClosed, ConnectionResetError):
380
- if not self._stopped.is_set():
380
+ if not self._stopped.is_set() and not channel.closed:
381
381
  raise
382
382
  except Exception as ex:
383
383
  logger.exception(
Binary file
Binary file
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xoscar
3
- Version: 0.4.4
3
+ Version: 0.4.6
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,7 @@
1
- xoscar-0.4.4.dist-info/RECORD,,
2
- xoscar-0.4.4.dist-info/WHEEL,sha256=2EkzLoFb7so8tT6oZZZ9qCoSorU44itt69ft8KTz84A,110
3
- xoscar-0.4.4.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
4
- xoscar-0.4.4.dist-info/METADATA,sha256=TuGS9WGtsTsESIq1SuBw9PeqUon1r14dsMrwZbJSQ-k,9042
1
+ xoscar-0.4.6.dist-info/RECORD,,
2
+ xoscar-0.4.6.dist-info/WHEEL,sha256=2EkzLoFb7so8tT6oZZZ9qCoSorU44itt69ft8KTz84A,110
3
+ xoscar-0.4.6.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
4
+ xoscar-0.4.6.dist-info/METADATA,sha256=mDlEVxaFePvqmKl3aoY9-bymXVVOYdX_Tw4S6qgSzso,9042
5
5
  xoscar/_utils.pyx,sha256=UR1FtYXAYKIdEWR9HulEpMbSOrkQWi6xGz63d4IQmG0,7059
6
6
  xoscar/backend.py,sha256=is436OPkZfSpQXaoqTRVta5eoye_pp45RFgCstAk2hU,1850
7
7
  xoscar/core.pxd,sha256=4lBq8J0kjcXcsGuvN7Kv4xcL5liHwTTFWlqyK7XAEnw,1280
@@ -10,7 +10,7 @@ xoscar/context.pxd,sha256=qKa0OyDPZtVymftSh447m-RzFZgmz8rGqQBa7qlauvc,725
10
10
  xoscar/batch.py,sha256=DpArS0L3WYJ_HVPG-6hSYEwoAFY1mY2-mlC4Jp5M_Dw,7872
11
11
  xoscar/nvutils.py,sha256=qmW4mKLU0WB2yCs198ccQOgLL02zB7Fsa-AotO3NOmg,20412
12
12
  xoscar/constants.py,sha256=QHHSREw6uWBBjQDCFqlNfTvBZgniJPGy42KSIsR8Fqw,787
13
- xoscar/_utils.cpython-310-darwin.so,sha256=a4qxNFbf6FmTCRgcHJI1H0WBs9lqj8XBa1Rw-3ZVdxg,167616
13
+ xoscar/_utils.cpython-310-darwin.so,sha256=3mjXgqVVyqJPzAZCIyXFLUr1GCIIwHrN1gqHbfwU0jI,167616
14
14
  xoscar/__init__.py,sha256=0zX8kKaio3ZIrlzB79WybcravMJw1OxPWjDspTgJFyQ,1608
15
15
  xoscar/api.py,sha256=3hztPoOxg8A_mlhWyWgVP7FMXG0PATA1TP4Rbaj7A-g,13327
16
16
  xoscar/utils.py,sha256=jUw6OICZUPBbmS1b3GE4vLctJf6fCKXrYtLtBuK-Oqc,16483
@@ -20,8 +20,8 @@ xoscar/context.pyx,sha256=8CdgPnWcE9eOp3N600WgDQ03MCi8P73eUOGcfV7Zksg,10942
20
20
  xoscar/errors.py,sha256=wBlQOKsXf0Fc4skN39tDie0YZT-VIAuLNRgoDl2pZcA,1241
21
21
  xoscar/core.pyx,sha256=Aqc2i8Fetsd5wRAPF4kL0ddnBZn3E2HRNCvup79BbQc,21730
22
22
  xoscar/driver.py,sha256=498fowtJr6b3FE8FIOA_Tc1Vwx88nfZw7p0FxrML0h4,1372
23
- xoscar/context.cpython-310-darwin.so,sha256=Dqm4OaZR1AFrIEE1dX72mf20zh3f30jVf32lWmRKk-0,210160
24
- xoscar/core.cpython-310-darwin.so,sha256=e5OmZSC_4Nf6CRKngmQuUXzHHbjS54TaBtLV-BWmytg,424856
23
+ xoscar/context.cpython-310-darwin.so,sha256=OkKLR1a5__0PgnaOku01fFYabmj7ysk75It6i68vGsQ,210160
24
+ xoscar/core.cpython-310-darwin.so,sha256=s2HfXOsSW9Q8gwVNRWowiKGQ1DimoFh62WiwstREQzU,424856
25
25
  xoscar/profiling.py,sha256=BC5OF0HzSaXv8V7w-y-B8r5gV5DgxHFoTEIF6jCMioQ,8015
26
26
  xoscar/_utils.pxd,sha256=5KYAL3jfPdejsHnrGGT2s--ZUX5SXznQWpHVSno429k,1157
27
27
  xoscar/metrics/__init__.py,sha256=9Badi7rxYikGm2dQiNCrj9GgMRBxwuR3JaEKcFZmfak,705
@@ -47,20 +47,20 @@ xoscar/serialization/cuda.py,sha256=iFUEnN4SiquBIhyieyOrfw3TnKnW-tU_vYgqOxO_DrA,
47
47
  xoscar/serialization/scipy.py,sha256=yOEi0NB8cqQ6e2UnCZ1w006RsB7T725tIL-DM_hNcsU,2482
48
48
  xoscar/serialization/aio.py,sha256=5DySPgDxU43ec7_5Ct44-Oqt7YNSJBfuf8VdQgQlChA,4731
49
49
  xoscar/serialization/core.pyx,sha256=bjR-zXGm9qersk7kYPzpjpMIxDl_Auur4BCubRfKmfA,29626
50
- xoscar/serialization/core.cpython-310-darwin.so,sha256=RoLQdwL3XYlfPMQIhOSfercGJ24NedclpfPmQQehniA,378952
50
+ xoscar/serialization/core.cpython-310-darwin.so,sha256=GeraV_NdHU-wgPg_vZWshmTBkaHBOFmAlvUe1YTKseE,378952
51
51
  xoscar/backends/config.py,sha256=EG26f0GwX_f4dAhwTW77RBjiK9h8R_3JrD-rBF1bAq8,4984
52
52
  xoscar/backends/allocate_strategy.py,sha256=tC1Nbq2tJohahUwd-zoRYHEDX65wyuX8tmeY45uWj_w,4845
53
- xoscar/backends/message.cpython-310-darwin.so,sha256=IA1lhiHJkheGiiZRcY4dyN4KTeoWg42HrEqa5wpjqzc,345264
53
+ xoscar/backends/message.cpython-310-darwin.so,sha256=T7ld6uEnd780WbLh6UW_9LUOoqPd2dPvWl2lMieEMLs,345264
54
54
  xoscar/backends/__init__.py,sha256=VHEBQcUWM5bj027W8EUf9PiJUAP7JoMrRw3Tsvy5ySw,643
55
- xoscar/backends/core.py,sha256=3hWgmVYddSy341wsinYOr0yFSlICC9SBr-KQ_KeJRLw,10262
55
+ xoscar/backends/core.py,sha256=rXJ73IC5lgERXCWvVrDEEyGAILlwVJs7XIWBCFUEVCc,10166
56
56
  xoscar/backends/context.py,sha256=Vr_PibRxYCDQ_gYK7r-BOlw9TXw8VQbFsVTH7K7mHPk,15470
57
57
  xoscar/backends/router.py,sha256=mhSvM5KVfV882jricVcpyxAqHEvhS4zL6ivczC6fOTE,7746
58
58
  xoscar/backends/message.pyx,sha256=uyzilPc_7SqNwGUL4U-Zbfqku8bfZyRW_Lt_S3I_LEU,17930
59
- xoscar/backends/pool.py,sha256=Z7Wdab9dBF3SdQpmzgZhY0d09oTvg5gpFgzYH7vuc4w,59841
59
+ xoscar/backends/pool.py,sha256=prpyQzJMp5ujFHaSnyhltlSFsnTxXh9D0pPzU6CCCb4,59864
60
60
  xoscar/backends/indigen/backend.py,sha256=znl_fZzWGEtLH8hZ9j9Kkf0fva25jEem2_KO7I1RVvc,1612
61
61
  xoscar/backends/indigen/__init__.py,sha256=tKHP5ClzedBRBpZsLRVErR3EUNbbDm4CY4u0rCFJr44,685
62
62
  xoscar/backends/indigen/driver.py,sha256=VGzkacYKykegW5qhCuhx01gdgBZEKJjNIyfNCnA6Nm8,952
63
- xoscar/backends/indigen/pool.py,sha256=mWYkOP4VVoUsXFgfpwruPuWblF6Waan5vxit8B-9_oQ,16852
63
+ xoscar/backends/indigen/pool.py,sha256=v0Ps79W0WyeFSt2YxCJnh7q_1dnRQmo9887gcW3pNoc,17226
64
64
  xoscar/backends/test/backend.py,sha256=nv9WFhH5Bbq4Q1HB9yfpciZBaeHT4IQAtzugBWESrUY,1263
65
65
  xoscar/backends/test/__init__.py,sha256=j2ZfD6prD9WjUxRUDC7Eq5Z7N7TkL6fFr59oNyc_vY4,682
66
66
  xoscar/backends/test/pool.py,sha256=TW4X6J-92Pti66103poQBNDBznX6CBD3RLOc_zixjTo,7257
@@ -69,8 +69,8 @@ xoscar/backends/communication/__init__.py,sha256=tB05BlK63iWQnfJgRzKt4mFKRtmWUki
69
69
  xoscar/backends/communication/core.py,sha256=sJeE3foRIqVPXldzYpFKHDSsabfAIFBU4JuXY4OyklY,2130
70
70
  xoscar/backends/communication/utils.py,sha256=AmovE-hmWLXNCPwHafYuaRjOk8m42BUyT3XBqfXQRVI,3664
71
71
  xoscar/backends/communication/errors.py,sha256=V3CdBe2xX9Rwv32f2dH2Msc84yaUhlyerZ42-739o1Q,723
72
- xoscar/backends/communication/socket.py,sha256=R9jF_Iy3HTSPXkBGrws5ckK-EjYnaPBSTdMqMZYqxqc,13972
73
- xoscar/backends/communication/dummy.py,sha256=sKBqoFkftm6ynV3p5UNGI4VYFGlrOHJgJlqj35PGAgk,8479
72
+ xoscar/backends/communication/socket.py,sha256=_1tuBZrSmdEC6c6QIj_7JQh23ruIIQPwySDMcrndzwA,14267
73
+ xoscar/backends/communication/dummy.py,sha256=6kLkxjNk4xTQ-IlNZD6cftNCx5UsGOur2jk7ikrNUCg,8157
74
74
  xoscar/backends/communication/base.py,sha256=0P4Tr35GSWpRp394e9jVWUUoKKa-gIk177eYPw1BnSU,7421
75
75
  xoscar/aio/__init__.py,sha256=kViDKR_kJe59VQViHITKEfBcIgN4ZJblUyd8zl0E3ZI,675
76
76
  xoscar/aio/file.py,sha256=PBtkLp-Q7XtYl-zk00s18TtgIrkNr60J3Itf66ctO1o,1486
File without changes