portal 3.0.0__tar.gz → 3.1.0__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.
- {portal-3.0.0/portal.egg-info → portal-3.1.0}/PKG-INFO +3 -3
- {portal-3.0.0 → portal-3.1.0}/README.md +2 -2
- {portal-3.0.0 → portal-3.1.0}/portal/__init__.py +1 -1
- {portal-3.0.0 → portal-3.1.0}/portal/client.py +1 -1
- {portal-3.0.0 → portal-3.1.0}/portal/client_socket.py +13 -7
- {portal-3.0.0 → portal-3.1.0}/portal/contextlib.py +4 -4
- {portal-3.0.0 → portal-3.1.0}/portal/server_socket.py +8 -3
- {portal-3.0.0 → portal-3.1.0/portal.egg-info}/PKG-INFO +3 -3
- {portal-3.0.0 → portal-3.1.0}/LICENSE +0 -0
- {portal-3.0.0 → portal-3.1.0}/MANIFEST.in +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/batching.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/buffers.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/packlib.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/poollib.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/process.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/server.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/sharray.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/thread.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal/utils.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal.egg-info/SOURCES.txt +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal.egg-info/dependency_links.txt +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal.egg-info/requires.txt +0 -0
- {portal-3.0.0 → portal-3.1.0}/portal.egg-info/top_level.txt +0 -0
- {portal-3.0.0 → portal-3.1.0}/pyproject.toml +0 -0
- {portal-3.0.0 → portal-3.1.0}/requirements.txt +0 -0
- {portal-3.0.0 → portal-3.1.0}/setup.cfg +0 -0
- {portal-3.0.0 → portal-3.1.0}/setup.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/tests/test_batching.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/tests/test_client.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/tests/test_errfile.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/tests/test_pack.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/tests/test_process.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/tests/test_server.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/tests/test_socket.py +0 -0
- {portal-3.0.0 → portal-3.1.0}/tests/test_thread.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: portal
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.1.0
|
4
4
|
Summary: Fast and reliable distributed systems in Python
|
5
5
|
Home-page: http://github.com/danijar/portal
|
6
6
|
Author: Danijar Hafner
|
@@ -20,8 +20,8 @@ Fast and reliable distributed systems in Python.
|
|
20
20
|
## Features
|
21
21
|
|
22
22
|
- 📡 **Communication:** Portal lets you bind functions to a `Server` and call
|
23
|
-
them from
|
24
|
-
automatically restore broken connections.
|
23
|
+
them from one or more `Client`s. Wait on results via `Future` objects.
|
24
|
+
Clients can automatically restore broken connections.
|
25
25
|
- 🚀 **Performance:** Optimized for throughput and latency. Array data is
|
26
26
|
zero-copy serialized and deserialized for throughput near the hardware limit.
|
27
27
|
- 🤸 **Flexibility:** Function inputs and outputs can be nested dicts and lists
|
@@ -7,8 +7,8 @@ Fast and reliable distributed systems in Python.
|
|
7
7
|
## Features
|
8
8
|
|
9
9
|
- 📡 **Communication:** Portal lets you bind functions to a `Server` and call
|
10
|
-
them from
|
11
|
-
automatically restore broken connections.
|
10
|
+
them from one or more `Client`s. Wait on results via `Future` objects.
|
11
|
+
Clients can automatically restore broken connections.
|
12
12
|
- 🚀 **Performance:** Optimized for throughput and latency. Array data is
|
13
13
|
zero-copy serialized and deserialized for throughput near the hardware limit.
|
14
14
|
- 🤸 **Flexibility:** Function inputs and outputs can be nested dicts and lists
|
@@ -12,7 +12,7 @@ from . import packlib
|
|
12
12
|
class Client:
|
13
13
|
|
14
14
|
def __init__(
|
15
|
-
self, host, port, name='Client', maxinflight=16, **kwargs):
|
15
|
+
self, host, port=None, name='Client', maxinflight=16, **kwargs):
|
16
16
|
assert 1 <= maxinflight, maxinflight
|
17
17
|
self.maxinflight = maxinflight
|
18
18
|
self.reqnum = iter(itertools.count(0))
|
@@ -29,6 +29,7 @@ class Options:
|
|
29
29
|
keepalive_every: float = 10
|
30
30
|
keepalive_fails: int = 10
|
31
31
|
logging: bool = True
|
32
|
+
logging_color: str = 'yellow'
|
32
33
|
|
33
34
|
|
34
35
|
class ClientSocket:
|
@@ -175,6 +176,7 @@ class ClientSocket:
|
|
175
176
|
once = True
|
176
177
|
while self.running:
|
177
178
|
sock, addr = self._create()
|
179
|
+
error = None
|
178
180
|
try:
|
179
181
|
# We need to resolve the address regularly.
|
180
182
|
if contextlib.context.resolver:
|
@@ -185,12 +187,12 @@ class ClientSocket:
|
|
185
187
|
self._log('Connection established')
|
186
188
|
return sock
|
187
189
|
except ConnectionError as e:
|
188
|
-
|
190
|
+
error = e
|
189
191
|
time.sleep(0.1)
|
190
|
-
except TimeoutError:
|
191
|
-
|
192
|
+
except TimeoutError as e:
|
193
|
+
error = e
|
192
194
|
if once:
|
193
|
-
self._log('Still trying to connect...')
|
195
|
+
self._log(f'Still trying to connect... ({error})')
|
194
196
|
once = False
|
195
197
|
sock.close()
|
196
198
|
return None
|
@@ -221,7 +223,11 @@ class ClientSocket:
|
|
221
223
|
return sock, addr
|
222
224
|
|
223
225
|
def _log(self, *args):
|
224
|
-
if self.options.logging:
|
225
|
-
|
226
|
+
if not self.options.logging:
|
227
|
+
return
|
228
|
+
if self.options.logging_color:
|
229
|
+
style = utils.style(color=self.options.logging_color)
|
226
230
|
reset = utils.style(reset=True)
|
227
|
-
|
231
|
+
else:
|
232
|
+
style, reset = '', ''
|
233
|
+
print(style + f'[{self.name}]' + reset, *args)
|
@@ -134,18 +134,18 @@ class Context:
|
|
134
134
|
|
135
135
|
def _watcher(self):
|
136
136
|
while True:
|
137
|
-
if self.done.wait(self.interval):
|
138
|
-
break
|
139
137
|
if self.errfile and self.errfile.exists():
|
140
138
|
print(f'Shutting down due to error file: {self.errfile}')
|
141
139
|
self.shutdown(2)
|
140
|
+
if self.done.wait(self.interval):
|
141
|
+
break
|
142
142
|
|
143
143
|
|
144
144
|
context = Context()
|
145
145
|
|
146
146
|
|
147
|
-
def initfn(fn):
|
148
|
-
context.initfn(fn)
|
147
|
+
def initfn(fn, call_now=True):
|
148
|
+
context.initfn(fn, call_now)
|
149
149
|
|
150
150
|
|
151
151
|
def setup(**kwargs):
|
@@ -31,6 +31,7 @@ class Options:
|
|
31
31
|
max_recv_queue: int = 4096
|
32
32
|
max_send_queue: int = 4096
|
33
33
|
logging: bool = True
|
34
|
+
logging_color: str = 'blue'
|
34
35
|
|
35
36
|
|
36
37
|
class ServerSocket:
|
@@ -161,7 +162,11 @@ class ServerSocket:
|
|
161
162
|
return sum(len(x.sendbufs) for x in self.conns.values())
|
162
163
|
|
163
164
|
def _log(self, *args, **kwargs):
|
164
|
-
if self.options.logging:
|
165
|
-
|
165
|
+
if not self.options.logging:
|
166
|
+
return
|
167
|
+
if self.options.logging_color:
|
168
|
+
style = utils.style(color=self.options.logging_color)
|
166
169
|
reset = utils.style(reset=True)
|
167
|
-
|
170
|
+
else:
|
171
|
+
style, reset = '', ''
|
172
|
+
print(style + f'[{self.name}]' + reset, *args)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
Metadata-Version: 2.1
|
2
2
|
Name: portal
|
3
|
-
Version: 3.
|
3
|
+
Version: 3.1.0
|
4
4
|
Summary: Fast and reliable distributed systems in Python
|
5
5
|
Home-page: http://github.com/danijar/portal
|
6
6
|
Author: Danijar Hafner
|
@@ -20,8 +20,8 @@ Fast and reliable distributed systems in Python.
|
|
20
20
|
## Features
|
21
21
|
|
22
22
|
- 📡 **Communication:** Portal lets you bind functions to a `Server` and call
|
23
|
-
them from
|
24
|
-
automatically restore broken connections.
|
23
|
+
them from one or more `Client`s. Wait on results via `Future` objects.
|
24
|
+
Clients can automatically restore broken connections.
|
25
25
|
- 🚀 **Performance:** Optimized for throughput and latency. Array data is
|
26
26
|
zero-copy serialized and deserialized for throughput near the hardware limit.
|
27
27
|
- 🤸 **Flexibility:** Function inputs and outputs can be nested dicts and lists
|
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
|