portal 3.7.1__tar.gz → 3.7.3__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.7.1/portal.egg-info → portal-3.7.3}/PKG-INFO +14 -2
- {portal-3.7.1 → portal-3.7.3}/portal/__init__.py +1 -1
- {portal-3.7.1 → portal-3.7.3}/portal/client_socket.py +1 -6
- {portal-3.7.1 → portal-3.7.3}/portal/packlib.py +6 -1
- {portal-3.7.1 → portal-3.7.3}/portal/server_socket.py +15 -11
- {portal-3.7.1 → portal-3.7.3/portal.egg-info}/PKG-INFO +14 -2
- {portal-3.7.1 → portal-3.7.3}/tests/test_pack.py +1 -0
- {portal-3.7.1 → portal-3.7.3}/LICENSE +0 -0
- {portal-3.7.1 → portal-3.7.3}/MANIFEST.in +0 -0
- {portal-3.7.1 → portal-3.7.3}/README.md +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/batching.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/buffers.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/client.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/contextlib.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/poollib.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/process.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/server.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/sharray.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/thread.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal/utils.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal.egg-info/SOURCES.txt +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal.egg-info/dependency_links.txt +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal.egg-info/requires.txt +0 -0
- {portal-3.7.1 → portal-3.7.3}/portal.egg-info/top_level.txt +0 -0
- {portal-3.7.1 → portal-3.7.3}/pyproject.toml +0 -0
- {portal-3.7.1 → portal-3.7.3}/requirements.txt +0 -0
- {portal-3.7.1 → portal-3.7.3}/setup.cfg +0 -0
- {portal-3.7.1 → portal-3.7.3}/setup.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/tests/test_batching.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/tests/test_client.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/tests/test_errfile.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/tests/test_process.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/tests/test_server.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/tests/test_socket.py +0 -0
- {portal-3.7.1 → portal-3.7.3}/tests/test_thread.py +0 -0
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: portal
|
3
|
-
Version: 3.7.
|
3
|
+
Version: 3.7.3
|
4
4
|
Summary: Fast and reliable distributed systems in Python
|
5
5
|
Home-page: http://github.com/danijar/portal
|
6
6
|
Author: Danijar Hafner
|
@@ -10,6 +10,18 @@ Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
11
11
|
Description-Content-Type: text/markdown
|
12
12
|
License-File: LICENSE
|
13
|
+
Requires-Dist: cloudpickle
|
14
|
+
Requires-Dist: msgpack
|
15
|
+
Requires-Dist: numpy
|
16
|
+
Requires-Dist: psutil
|
17
|
+
Dynamic: author
|
18
|
+
Dynamic: author-email
|
19
|
+
Dynamic: classifier
|
20
|
+
Dynamic: description
|
21
|
+
Dynamic: description-content-type
|
22
|
+
Dynamic: home-page
|
23
|
+
Dynamic: requires-dist
|
24
|
+
Dynamic: summary
|
13
25
|
|
14
26
|
[](https://pypi.python.org/pypi/portal/#history)
|
15
27
|
|
@@ -207,7 +207,7 @@ class ClientSocket:
|
|
207
207
|
sock.settimeout(10)
|
208
208
|
sock.connect(addr)
|
209
209
|
self._log('Connection established')
|
210
|
-
self.
|
210
|
+
sock.sendall(self.options.handshake.encode('utf-8'))
|
211
211
|
sock.settimeout(0)
|
212
212
|
return sock
|
213
213
|
except TimeoutError as e:
|
@@ -252,11 +252,6 @@ class ClientSocket:
|
|
252
252
|
|
253
253
|
return sock
|
254
254
|
|
255
|
-
def _send_handshake(self, sock):
|
256
|
-
buf = buffers.SendBuffer(self.options.handshake.encode('utf-8'))
|
257
|
-
while not buf.done():
|
258
|
-
buf.send(sock)
|
259
|
-
|
260
255
|
def _log(self, *args):
|
261
256
|
if not self.options.logging:
|
262
257
|
return
|
@@ -1,3 +1,4 @@
|
|
1
|
+
import math
|
1
2
|
import struct
|
2
3
|
|
3
4
|
import msgpack
|
@@ -30,7 +31,8 @@ def pack(data):
|
|
30
31
|
"Array is not contiguous in memory. Use " +
|
31
32
|
"np.asarray(arr, order='C') before passing the data into pack().")
|
32
33
|
specs.append(['array', value.shape, value.dtype.str])
|
33
|
-
|
34
|
+
buffer = value.data.cast('c') if value.size else b'\x00'
|
35
|
+
buffers.append(buffer)
|
34
36
|
elif isinstance(value, sharray.SharedArray):
|
35
37
|
specs.append(['sharray', *value.__getstate__()])
|
36
38
|
buffers.append(b'\x00')
|
@@ -64,6 +66,9 @@ def unpack(buffer):
|
|
64
66
|
leaves.append(buffer)
|
65
67
|
elif spec[0] == 'array':
|
66
68
|
shape, dtype = spec[1:]
|
69
|
+
if not math.prod(shape):
|
70
|
+
assert buffer == b'\x00'
|
71
|
+
buffer = b''
|
67
72
|
leaves.append(np.frombuffer(buffer, dtype).reshape(shape))
|
68
73
|
elif spec[0] == 'sharray':
|
69
74
|
assert buffer == b'\x00'
|
@@ -16,7 +16,7 @@ class Connection:
|
|
16
16
|
self.sock = sock
|
17
17
|
self.addr = addr
|
18
18
|
self.recvbuf = None
|
19
|
-
self.handshake =
|
19
|
+
self.handshake = b''
|
20
20
|
self.sendbufs = collections.deque()
|
21
21
|
|
22
22
|
def fileno(self):
|
@@ -44,6 +44,7 @@ class ServerSocket:
|
|
44
44
|
port = int(port.rsplit(':', 1)[-1])
|
45
45
|
self.name = name
|
46
46
|
self.options = Options(**{**contextlib.context.serverkw, **kwargs})
|
47
|
+
self.handshake = self.options.handshake.encode('utf-8')
|
47
48
|
if self.options.ipv6:
|
48
49
|
self.sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
|
49
50
|
self.sock.setsockopt(socket.IPPROTO_IPV6, socket.IPV6_V6ONLY, 1)
|
@@ -152,7 +153,11 @@ class ServerSocket:
|
|
152
153
|
if not conn.recvbuf:
|
153
154
|
conn.recvbuf = buffers.RecvBuffer(maxsize=self.options.max_msg_size)
|
154
155
|
try:
|
155
|
-
conn.
|
156
|
+
if len(conn.handshake) < len(self.handshake):
|
157
|
+
self._handshake(conn)
|
158
|
+
return
|
159
|
+
else:
|
160
|
+
conn.recvbuf.recv(conn.sock)
|
156
161
|
except OSError as e:
|
157
162
|
# For example:
|
158
163
|
# - ConnectionResetError
|
@@ -163,16 +168,8 @@ class ServerSocket:
|
|
163
168
|
return
|
164
169
|
if self.recvq.qsize() > self.options.max_recv_queue:
|
165
170
|
raise RuntimeError('Too many incoming messages enqueued')
|
166
|
-
|
171
|
+
self.recvq.put((conn.addr, conn.recvbuf.result()))
|
167
172
|
conn.recvbuf = None
|
168
|
-
if not conn.handshake:
|
169
|
-
if message != self.options.handshake.encode('utf-8'):
|
170
|
-
e = ValueError(f"Handshake '{self.options.handshake}' expected")
|
171
|
-
self._disconnect(conn, e)
|
172
|
-
return
|
173
|
-
conn.handshake = True
|
174
|
-
else:
|
175
|
-
self.recvq.put((conn.addr, message))
|
176
173
|
|
177
174
|
def _disconnect(self, conn, e):
|
178
175
|
detail = f'{type(e).__name__}'
|
@@ -189,6 +186,13 @@ class ServerSocket:
|
|
189
186
|
def _numsending(self):
|
190
187
|
return sum(len(x.sendbufs) for x in self.conns.values())
|
191
188
|
|
189
|
+
def _handshake(self, conn):
|
190
|
+
assert len(conn.handshake) < len(self.handshake)
|
191
|
+
conn.handshake += conn.sock.recv(len(self.handshake) - len(conn.handshake))
|
192
|
+
if conn.handshake != self.handshake[:len(conn.handshake)]:
|
193
|
+
msg = f"Expected handshake '{self.handshake}' got '{conn.handshake}'"
|
194
|
+
self._disconnect(conn, ValueError(msg))
|
195
|
+
|
192
196
|
def _log(self, *args, **kwargs):
|
193
197
|
if not self.options.logging:
|
194
198
|
return
|
@@ -1,6 +1,6 @@
|
|
1
|
-
Metadata-Version: 2.
|
1
|
+
Metadata-Version: 2.2
|
2
2
|
Name: portal
|
3
|
-
Version: 3.7.
|
3
|
+
Version: 3.7.3
|
4
4
|
Summary: Fast and reliable distributed systems in Python
|
5
5
|
Home-page: http://github.com/danijar/portal
|
6
6
|
Author: Danijar Hafner
|
@@ -10,6 +10,18 @@ Classifier: License :: OSI Approved :: MIT License
|
|
10
10
|
Classifier: Programming Language :: Python :: 3
|
11
11
|
Description-Content-Type: text/markdown
|
12
12
|
License-File: LICENSE
|
13
|
+
Requires-Dist: cloudpickle
|
14
|
+
Requires-Dist: msgpack
|
15
|
+
Requires-Dist: numpy
|
16
|
+
Requires-Dist: psutil
|
17
|
+
Dynamic: author
|
18
|
+
Dynamic: author-email
|
19
|
+
Dynamic: classifier
|
20
|
+
Dynamic: description
|
21
|
+
Dynamic: description-content-type
|
22
|
+
Dynamic: home-page
|
23
|
+
Dynamic: requires-dist
|
24
|
+
Dynamic: summary
|
13
25
|
|
14
26
|
[](https://pypi.python.org/pypi/portal/#history)
|
15
27
|
|
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
|