xoscar 0.4.0__cp311-cp311-win_amd64.whl → 0.4.1__cp311-cp311-win_amd64.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
@@ -29,7 +29,7 @@ from typing import Any, Callable, Coroutine, Dict, Type
29
29
  from urllib.parse import urlparse
30
30
 
31
31
  from ..._utils import to_binary
32
- from ...constants import XOSCAR_UNIX_SOCKET_DIR
32
+ from ...constants import XOSCAR_CONNECT_TIMEOUT, XOSCAR_UNIX_SOCKET_DIR
33
33
  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
@@ -291,7 +291,13 @@ class SocketClient(Client):
291
291
  ) -> "Client":
292
292
  host, port_str = dest_address.rsplit(":", 1)
293
293
  port = int(port_str)
294
- (reader, writer) = await asyncio.open_connection(host=host, port=port, **kwargs)
294
+ config = kwargs.get("config", {})
295
+ connect_timeout = config.get("connect_timeout", XOSCAR_CONNECT_TIMEOUT)
296
+ fut = asyncio.open_connection(host=host, port=port)
297
+ try:
298
+ reader, writer = await asyncio.wait_for(fut, timeout=connect_timeout)
299
+ except asyncio.TimeoutError:
300
+ raise ConnectionError("connect timeout")
295
301
  channel = SocketChannel(
296
302
  reader, writer, local_address=local_address, dest_address=dest_address
297
303
  )
xoscar/backends/core.py CHANGED
@@ -70,50 +70,61 @@ class ActorCaller:
70
70
  return client
71
71
 
72
72
  async def _listen(self, client: Client):
73
- while not client.closed:
74
- try:
73
+ try:
74
+ while not client.closed:
75
75
  try:
76
- message: _MessageBase = await client.recv()
77
- except (EOFError, ConnectionError, BrokenPipeError):
78
- # remote server closed, close client and raise ServerClosed
79
76
  try:
80
- await client.close()
81
- except (ConnectionError, BrokenPipeError):
82
- # close failed, ignore it
77
+ message: _MessageBase = await client.recv()
78
+ except (EOFError, ConnectionError, BrokenPipeError) as e:
79
+ # AssertionError is from get_header
80
+ # remote server closed, close client and raise ServerClosed
81
+ logger.debug(f"{client.dest_address} close due to {e}")
82
+ try:
83
+ await client.close()
84
+ except (ConnectionError, BrokenPipeError):
85
+ # close failed, ignore it
86
+ pass
87
+ raise ServerClosed(
88
+ f"Remote server {client.dest_address} closed: {e}"
89
+ ) from None
90
+ future = self._client_to_message_futures[client].pop(
91
+ message.message_id
92
+ )
93
+ if not future.done():
94
+ future.set_result(message)
95
+ except DeserializeMessageFailed as e:
96
+ message_id = e.message_id
97
+ future = self._client_to_message_futures[client].pop(message_id)
98
+ future.set_exception(e.__cause__) # type: ignore
99
+ except Exception as e: # noqa: E722 # pylint: disable=bare-except
100
+ message_futures = self._client_to_message_futures[client]
101
+ self._client_to_message_futures[client] = dict()
102
+ for future in message_futures.values():
103
+ future.set_exception(copy.copy(e))
104
+ finally:
105
+ # message may have Ray ObjectRef, delete it early in case next loop doesn't run
106
+ # as soon as expected.
107
+ try:
108
+ del message
109
+ except NameError:
83
110
  pass
84
- raise ServerClosed(
85
- f"Remote server {client.dest_address} closed"
86
- ) from None
87
- future = self._client_to_message_futures[client].pop(message.message_id)
88
- if not future.done():
89
- future.set_result(message)
90
- except DeserializeMessageFailed as e:
91
- message_id = e.message_id
92
- future = self._client_to_message_futures[client].pop(message_id)
93
- future.set_exception(e.__cause__) # type: ignore
94
- except Exception as e: # noqa: E722 # pylint: disable=bare-except
95
- message_futures = self._client_to_message_futures[client]
96
- self._client_to_message_futures[client] = dict()
97
- for future in message_futures.values():
98
- future.set_exception(copy.copy(e))
99
- finally:
100
- # message may have Ray ObjectRef, delete it early in case next loop doesn't run
101
- # as soon as expected.
102
- try:
103
- del message
104
- except NameError:
105
- pass
106
- try:
107
- del future
108
- except NameError:
109
- pass
110
- await asyncio.sleep(0)
111
+ try:
112
+ del future
113
+ except NameError:
114
+ pass
115
+ await asyncio.sleep(0)
111
116
 
112
- message_futures = self._client_to_message_futures[client]
113
- self._client_to_message_futures[client] = dict()
114
- error = ServerClosed(f"Remote server {client.dest_address} closed")
115
- for future in message_futures.values():
116
- future.set_exception(copy.copy(error))
117
+ message_futures = self._client_to_message_futures[client]
118
+ self._client_to_message_futures[client] = dict()
119
+ error = ServerClosed(f"Remote server {client.dest_address} closed")
120
+ for future in message_futures.values():
121
+ future.set_exception(copy.copy(error))
122
+ finally:
123
+ try:
124
+ await client.close()
125
+ except: # noqa: E722 # nosec # pylint: disable=bare-except
126
+ # ignore all error if fail to close at last
127
+ pass
117
128
 
118
129
  async def call_with_client(
119
130
  self, client: Client, message: _MessageBase, wait: bool = True
Binary file
xoscar/backends/pool.py CHANGED
@@ -551,23 +551,31 @@ class AbstractActorPool(ABC):
551
551
  return False
552
552
 
553
553
  async def on_new_channel(self, channel: Channel):
554
- while not self._stopped.is_set():
555
- try:
556
- message = await channel.recv()
557
- except EOFError:
558
- # no data to read, check channel
554
+ try:
555
+ while not self._stopped.is_set():
559
556
  try:
560
- await channel.close()
561
- except (ConnectionError, EOFError):
562
- # close failed, ignore
563
- pass
564
- return
565
- if await self._handle_ucx_meta_message(message, channel):
566
- continue
567
- asyncio.create_task(self.process_message(message, channel))
568
- # delete to release the reference of message
569
- del message
570
- await asyncio.sleep(0)
557
+ message = await channel.recv()
558
+ except (EOFError, ConnectionError, BrokenPipeError) as e:
559
+ logger.debug(f"pool: close connection due to {e}")
560
+ # no data to read, check channel
561
+ try:
562
+ await channel.close()
563
+ except (ConnectionError, EOFError):
564
+ # close failed, ignore
565
+ pass
566
+ return
567
+ if await self._handle_ucx_meta_message(message, channel):
568
+ continue
569
+ asyncio.create_task(self.process_message(message, channel))
570
+ # delete to release the reference of message
571
+ del message
572
+ await asyncio.sleep(0)
573
+ finally:
574
+ try:
575
+ await channel.close()
576
+ except: # noqa: E722 # nosec # pylint: disable=bare-except
577
+ # ignore all error if fail to close at last
578
+ pass
571
579
 
572
580
  async def __aenter__(self):
573
581
  await self.start()
xoscar/collective/uv.dll CHANGED
Binary file
xoscar/constants.py CHANGED
@@ -19,3 +19,5 @@ XOSCAR_TEMP_DIR = Path(os.getenv("XOSCAR_DIR", Path.home())) / ".xoscar"
19
19
 
20
20
  # unix socket.
21
21
  XOSCAR_UNIX_SOCKET_DIR = XOSCAR_TEMP_DIR / "socket"
22
+
23
+ XOSCAR_CONNECT_TIMEOUT = 8
Binary file
Binary file
@@ -77,7 +77,11 @@ MALFORMED_MSG = "Received malformed data, please check Xoscar version on both si
77
77
  def get_header_length(header_bytes: bytes):
78
78
  version = struct.unpack("B", header_bytes[:1])[0]
79
79
  # now we only have default version
80
- assert version == DEFAULT_SERIALIZATION_VERSION, MALFORMED_MSG
80
+ if version != DEFAULT_SERIALIZATION_VERSION:
81
+ # when version not matched,
82
+ # we will immediately abort the connection
83
+ # EOFError will be captured by channel
84
+ raise EOFError(MALFORMED_MSG)
81
85
  # header length
82
86
  header_length = struct.unpack("<Q", header_bytes[1:9])[0]
83
87
  # compress
xoscar/utils.py CHANGED
@@ -19,11 +19,11 @@ import asyncio
19
19
  import dataclasses
20
20
  import functools
21
21
  import importlib
22
+ import importlib.util as importlib_utils
22
23
  import inspect
23
24
  import io
24
25
  import logging
25
26
  import os
26
- import pkgutil
27
27
  import random
28
28
  import socket
29
29
  import sys
@@ -267,7 +267,7 @@ def lazy_import(
267
267
  self._on_loads.append(func)
268
268
  return func
269
269
 
270
- if pkgutil.find_loader(prefix_name) is not None:
270
+ if importlib_utils.find_spec(prefix_name) is not None:
271
271
  return LazyModule()
272
272
  elif placeholder:
273
273
  return ModulePlaceholder(prefix_name)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: xoscar
3
- Version: 0.4.0
3
+ Version: 0.4.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,16 +1,16 @@
1
1
  xoscar/__init__.py,sha256=dlwtB7dnDp5WME6CZVQY7d9lk1yJ9s___H5UxjGlAd4,1668
2
- xoscar/_utils.cp311-win_amd64.pyd,sha256=Oy3ArtgPdp-NpVSqzb4YdSJvx-zRIIOAb36-S7EBsbQ,113152
2
+ xoscar/_utils.cp311-win_amd64.pyd,sha256=p43CWPNA7-X9rgsb1maBbKbWFQf4J4Ol2GjR2gKGa2E,113152
3
3
  xoscar/_utils.pxd,sha256=rlNbTg5lhXA-jCOLksqF4jhUlNn0xw2jx1HxdLa34pc,1193
4
4
  xoscar/_utils.pyx,sha256=5Wvind3AQ3JaMK7Zv9SjhiPO6LEol2hW7_fMncn69go,7300
5
5
  xoscar/_version.py,sha256=bsfCVAo_o9LkiP3AjPsP4SRRqhjuS0t4D1WGJPzbdls,24412
6
6
  xoscar/api.py,sha256=B5oXv4vgMxMteh1YNaBmNFDrUFmYa_dCdzfaWwwZnCo,13820
7
7
  xoscar/backend.py,sha256=8G5JwjoOT6Q2slb11eXNApxgcmvNQUCdQzkoIMDwLcQ,1917
8
8
  xoscar/batch.py,sha256=Jk5BSpvMFAV9DrRy0a9tgPvIo_dt8cbJReZBL0cnOPc,8128
9
- xoscar/constants.py,sha256=H9ntCahBz5nKO-A6rkrGKy4WB2kNaLZAytkDajKIXqM,780
10
- xoscar/context.cp311-win_amd64.pyd,sha256=HNo_x-jnnSfkOGEDxSBvSfTGBP5XIYF35omPvVzhBv8,155648
9
+ xoscar/constants.py,sha256=GJ1KEOxwnqksc9K_GH42TSWpQECeC6ti3KJmE3PUcTw,810
10
+ xoscar/context.cp311-win_amd64.pyd,sha256=K2Lf2gp4cAVKfQR8c5dHIa5PkNHABTGdmsrnC49aP3I,155648
11
11
  xoscar/context.pxd,sha256=6n6IAbmArSRq8EjcsbS6npW8xP1jI0qOoS1fF0oyj-o,746
12
12
  xoscar/context.pyx,sha256=FOJVerGOvxe2USryXEQA0rpaFX_ScxISH6QWKUcahY8,11310
13
- xoscar/core.cp311-win_amd64.pyd,sha256=tUrxztCXfScOqSdrcKJBp3GXq1kChEcSeygAuRwc2ks,324608
13
+ xoscar/core.cp311-win_amd64.pyd,sha256=q9bN4vQ6XYGcvRAI2nfWbs65NB3ZjcGC8tZQqV8OBnY,324608
14
14
  xoscar/core.pxd,sha256=dGv62H92PFG98SVILuF641kY-NWFEt1FYqqOX3WY5RQ,1330
15
15
  xoscar/core.pyx,sha256=0YvJW2AHgymyfsAlPGvIFw65J5gTKO3PK2p1wl4VlJ0,22388
16
16
  xoscar/debug.py,sha256=hrmxIH6zvTKasQo6PUUgXu5mgEsR0g87Fvpw7CoHipg,5257
@@ -19,7 +19,7 @@ xoscar/errors.py,sha256=hfIAlYuSVfB3dAQYr8hTLAMmfy5en6Y8mihdtw1gTEE,1304
19
19
  xoscar/libcpp.pxd,sha256=XGy887HXdRsvF47s-A7PvHX6Gaf15d_azRscWJY0Hc8,1178
20
20
  xoscar/nvutils.py,sha256=z6RCVs0sgKFm55TTgAYG3qy5f_AKJzjcH2kcRB-wTJQ,21129
21
21
  xoscar/profiling.py,sha256=LUqkj6sSxaFj0ltS7Yk2kFsh5ieHY417xypTYHwQOb4,8275
22
- xoscar/utils.py,sha256=kLY5cp3tHM9CaEzFG82v7f8XepxC3YZXAUCg5o1uRJ0,16968
22
+ xoscar/utils.py,sha256=wiDLdRUi4hgdrKVehzDMVRpym8oEcbdpo900o3BpoMM,17000
23
23
  xoscar/aio/__init__.py,sha256=ZLJlVJJH5EhItKD6tLTBri-4FV4kT1O2qdIfBC-df98,691
24
24
  xoscar/aio/base.py,sha256=ytknTCjTjNQbTM7l7QGXqPYYUkD7qq-zVBGVZ34L1Tc,2335
25
25
  xoscar/aio/file.py,sha256=x1wrvDgtTFMv-6gjSPpBU26jAO5uEAlXGGnFtx7uevQ,1545
@@ -29,17 +29,17 @@ xoscar/backends/__init__.py,sha256=g9OllTquu9MRB5nySVoyiRv2z-_OSALWrOhwt7L9WXc,6
29
29
  xoscar/backends/allocate_strategy.py,sha256=DzvTlixwzTANURI2mDLHm3vcaugSPDxU6UQZb89KH0U,5005
30
30
  xoscar/backends/config.py,sha256=7nmvU_19zYR7n-bT8BNasbjntwmobmMiM7wN7O6Lujc,5129
31
31
  xoscar/backends/context.py,sha256=NukXzBwq9ZwuiN1y6RE1hfNGsW589hDtJAVwu-DV9E0,15874
32
- xoscar/backends/core.py,sha256=bVQxM1E4qMq1-SkfrZM1aolNg1WQv2sHcZxWI1ETyMM,7625
33
- xoscar/backends/message.cp311-win_amd64.pyd,sha256=ssqPztkmpdXoEoQzst9XyilrdDqYzQLH8q-U7B8YJf0,265216
32
+ xoscar/backends/core.py,sha256=TNf-ROrmVixN9A82Fh1gh1UkqBdBZJd1_nlMtP4A0Bw,8243
33
+ xoscar/backends/message.cp311-win_amd64.pyd,sha256=DWvTqjCRLRx7uHETAnzSX2N8XUM5whNhY5j0Kq3PW54,265216
34
34
  xoscar/backends/message.pyx,sha256=23j-fjxOVONPWY0-C5sfCOMbZCx4PTxN0GU8YfrLNeg,18529
35
- xoscar/backends/pool.py,sha256=DpOwcqXsAy-SJUbHKxsVrwRIzp3VSIqyy2uvM2Kt34A,61017
35
+ xoscar/backends/pool.py,sha256=nh2DTrcOrZc75TG2v7MXeGLMLhEO4GsObD7zirymZ3c,61445
36
36
  xoscar/backends/router.py,sha256=GJpSV_LhzINHdTp5jtsMHfPNMkNb1KI-WlqGqhwApGU,7953
37
37
  xoscar/backends/communication/__init__.py,sha256=Z0_RJkPGwLJeapSNt-TiO9DvnpBPu8P4PCooLaAqjkk,1080
38
38
  xoscar/backends/communication/base.py,sha256=wmWTeE4lcB_ohqyJJ6MdzMGcrOqy2RSKRp8y-NDuFdY,7736
39
39
  xoscar/backends/communication/core.py,sha256=ZM_fU0yokoPzXcJ6j-89llp2r7J9pl3gE5iImn4b4bE,2199
40
40
  xoscar/backends/communication/dummy.py,sha256=apbkfFdVWqeqc8Cc1LInOw6ikVoFWixTwBN__djxgBY,8040
41
41
  xoscar/backends/communication/errors.py,sha256=-O6ZaKs6Gz7g_ZnKU2wrz8D9btowqaYuQ9u0zCYSLWo,743
42
- xoscar/backends/communication/socket.py,sha256=FAEU9wu-_VcSw0jBCtyBZ83XB5-Jg0qAyMUrf0zxZl4,13803
42
+ xoscar/backends/communication/socket.py,sha256=sq9abnWvngA55Sxz3TV0nL4JuxZX79DgTQn8E3xbRXY,14111
43
43
  xoscar/backends/communication/ucx.py,sha256=defQN2sirsu-KqvXox_I_wzAfWSq5LJkjKdzo0vtPgw,20234
44
44
  xoscar/backends/communication/utils.py,sha256=F-muF5_ow9JzAPAZ3d8XaGDiz3bRZOdWmWBDwQOVLe0,3761
45
45
  xoscar/backends/indigen/__init__.py,sha256=Khr2aGbaIw_04NIdY7QNhdljCKbmmzLb4NeAOM3LF8M,701
@@ -54,8 +54,8 @@ xoscar/collective/common.py,sha256=9c7xq3IOUvfA0I9GnpalUqXZOzmF6IEILv4zL64BYVE,3
54
54
  xoscar/collective/core.py,sha256=191aPxbUgWpjzrqyozndImDAQhZFmqoQdBkHFLDfXN0,24239
55
55
  xoscar/collective/process_group.py,sha256=kTPbrLMJSGhqbiWvTIiz-X3W0rZWd_CFn_zUIlXbOlM,23286
56
56
  xoscar/collective/utils.py,sha256=p3WEVtXvnVhkuO5mRgQBhBRFr1dKHcDKMjrbMyuiyfg,1219
57
- xoscar/collective/uv.dll,sha256=QDV2lLhvDu20ut8qtTA5QDvI5iGTRjL5f1A7KT175ak,620544
58
- xoscar/collective/xoscar_pygloo.cp311-win_amd64.pyd,sha256=WVQ6aUzoKWw9k-jYhj1z1-SU63KwL19ff0czKtnTQJU,825344
57
+ xoscar/collective/uv.dll,sha256=xkaNmdaNHfNNm2KqBb3ZgTPYQjYBCQRY5uaP8UZTvd0,620544
58
+ xoscar/collective/xoscar_pygloo.cp311-win_amd64.pyd,sha256=CqC9TnOhXeQloZkfSwzWsBnD2g1NZvwfa-N8hGYBGek,823808
59
59
  xoscar/metrics/__init__.py,sha256=RjXuuYw4I2YYgD8UY2Z5yCZk0Z56xMJ1n40O80Dtxf8,726
60
60
  xoscar/metrics/api.py,sha256=dtJ4QrIqQNXhJedeqOPs4TXKgrRGZFFN50xAd9SCfec,9144
61
61
  xoscar/metrics/backends/__init__.py,sha256=ZHepfhCDRuK9yz4pAM7bjpWDvS3Ijp1YgyynoUFLeuU,594
@@ -65,8 +65,8 @@ xoscar/metrics/backends/console/console_metric.py,sha256=o6uGA65Kp3yvkMSGKrIilD2
65
65
  xoscar/metrics/backends/prometheus/__init__.py,sha256=ZHepfhCDRuK9yz4pAM7bjpWDvS3Ijp1YgyynoUFLeuU,594
66
66
  xoscar/metrics/backends/prometheus/prometheus_metric.py,sha256=65hb8O3tmsEJ7jgOrIwl_suj9SE5Tmqcfjuk0urkLvE,2120
67
67
  xoscar/serialization/__init__.py,sha256=NOAn046vnHEkx--82BKNinV8EpyOfT5hqfRBGnKl56s,866
68
- xoscar/serialization/aio.py,sha256=bL31B2lwrEKA5nztRSeSgDyqsbBN6dCMr6rHwNDGAIk,4715
69
- xoscar/serialization/core.cp311-win_amd64.pyd,sha256=NShvfJmEfgsiKdsTr6ggthbqjsUGFmS6-fSr32yIW_U,293888
68
+ xoscar/serialization/aio.py,sha256=7YLXgkWpQ3ANy-TZ1qO8Mt4_J3cZFhFh2FEgUgxMT60,4873
69
+ xoscar/serialization/core.cp311-win_amd64.pyd,sha256=sYdY4-javrZxbWDN4xnme4Mrt7Cve6X9VcEcvbQQblo,293376
70
70
  xoscar/serialization/core.pxd,sha256=X-47bqBM2Kzw5SkLqICdKD0gU6CpmLsBxC3kfW--wVk,1013
71
71
  xoscar/serialization/core.pyx,sha256=ZKexLRnRwZXXn2045kR7xfM_szcoPNrDuouQCWtpFp8,30570
72
72
  xoscar/serialization/cuda.py,sha256=Fj4Cpr_YmkGceUCo0mQn8fRvmHP_5WcLdRx6epZ3RC0,3869
@@ -74,7 +74,7 @@ xoscar/serialization/exception.py,sha256=t6yZn_Ate04UE1RbabNh7mu739sdtwarjuPXWhA
74
74
  xoscar/serialization/numpy.py,sha256=C6WVx-Sdl2OHBAvVY34DFjAKXlekMbpc2ni6bR8wxYo,3001
75
75
  xoscar/serialization/pyfury.py,sha256=3ucal29Hr7PX9_1SfB2x43FE2xw_C0rLkVv3foL7qwM,1200
76
76
  xoscar/serialization/scipy.py,sha256=9ph-yoRoNiwUZTwQrn35U60VPirWlncXNAg6EXvqMR4,2554
77
- xoscar-0.4.0.dist-info/METADATA,sha256=4q4G5TFvvYLHA9zH_ZTmgwu-7DwtRbiXsllkbuu-UPA,9265
78
- xoscar-0.4.0.dist-info/WHEEL,sha256=yEpuRje-u1Z_HrXQj-UTAfIAegW_HcP2GJ7Ek8BJkUM,102
79
- xoscar-0.4.0.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
80
- xoscar-0.4.0.dist-info/RECORD,,
77
+ xoscar-0.4.1.dist-info/METADATA,sha256=BfnUJHhYjnOGtAknk32D1ACdmTse9w3dZ-tE-NoIXQE,9265
78
+ xoscar-0.4.1.dist-info/WHEEL,sha256=y4n9_669c4ZQLyT56MHjc_JUbnwtaZfMVMycweN557o,102
79
+ xoscar-0.4.1.dist-info/top_level.txt,sha256=vYlqqY4Nys8Thm1hePIuUv8eQePdULVWMmt7lXtX_ZA,21
80
+ xoscar-0.4.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: bdist_wheel (0.44.0)
2
+ Generator: bdist_wheel (0.45.1)
3
3
  Root-Is-Purelib: false
4
4
  Tag: cp311-cp311-win_amd64
5
5