xoscar 0.4.0__tar.gz → 0.4.1__tar.gz
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-0.4.0/xoscar.egg-info → xoscar-0.4.1}/PKG-INFO +1 -1
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/communication/socket.py +8 -2
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/core.py +51 -40
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/pool.py +24 -16
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/constants.py +2 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/aio.py +5 -1
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/utils.py +2 -2
- {xoscar-0.4.0 → xoscar-0.4.1/xoscar.egg-info}/PKG-INFO +1 -1
- {xoscar-0.4.0 → xoscar-0.4.1}/MANIFEST.in +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/pyproject.toml +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/setup.cfg +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/setup.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/versioneer.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/_utils.pxd +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/_utils.pyx +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/_version.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/aio/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/aio/base.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/aio/file.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/aio/lru.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/aio/parallelism.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/api.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backend.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/allocate_strategy.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/communication/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/communication/base.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/communication/core.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/communication/dummy.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/communication/errors.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/communication/ucx.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/communication/utils.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/config.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/context.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/indigen/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/indigen/backend.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/indigen/driver.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/indigen/pool.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/message.pyx +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/router.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/test/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/test/backend.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/backends/test/pool.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/batch.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/collective/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/collective/common.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/collective/core.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/collective/process_group.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/collective/utils.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/context.pxd +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/context.pyx +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/core.pxd +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/core.pyx +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/debug.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/driver.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/errors.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/libcpp.pxd +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/metrics/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/metrics/api.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/metrics/backends/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/metrics/backends/console/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/metrics/backends/console/console_metric.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/metrics/backends/metric.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/metrics/backends/prometheus/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/metrics/backends/prometheus/prometheus_metric.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/nvutils.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/profiling.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/__init__.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/core.pxd +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/core.pyx +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/cuda.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/exception.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/numpy.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/pyfury.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar/serialization/scipy.py +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar.egg-info/SOURCES.txt +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar.egg-info/dependency_links.txt +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar.egg-info/not-zip-safe +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar.egg-info/requires.txt +0 -0
- {xoscar-0.4.0 → xoscar-0.4.1}/xoscar.egg-info/top_level.txt +0 -0
|
@@ -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
|
-
|
|
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
|
)
|
|
@@ -70,50 +70,61 @@ class ActorCaller:
|
|
|
70
70
|
return client
|
|
71
71
|
|
|
72
72
|
async def _listen(self, client: Client):
|
|
73
|
-
|
|
74
|
-
|
|
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.
|
|
81
|
-
except (ConnectionError, BrokenPipeError):
|
|
82
|
-
#
|
|
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
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
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
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
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
|
|
@@ -551,23 +551,31 @@ class AbstractActorPool(ABC):
|
|
|
551
551
|
return False
|
|
552
552
|
|
|
553
553
|
async def on_new_channel(self, channel: Channel):
|
|
554
|
-
|
|
555
|
-
|
|
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.
|
|
561
|
-
except (ConnectionError,
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
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()
|
|
@@ -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
|
-
|
|
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
|
|
@@ -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
|
|
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)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|