portal 3.0.0__tar.gz → 3.1.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.
Files changed (35) hide show
  1. {portal-3.0.0/portal.egg-info → portal-3.1.1}/PKG-INFO +3 -3
  2. {portal-3.0.0 → portal-3.1.1}/README.md +2 -2
  3. {portal-3.0.0 → portal-3.1.1}/portal/__init__.py +1 -1
  4. {portal-3.0.0 → portal-3.1.1}/portal/client.py +1 -1
  5. {portal-3.0.0 → portal-3.1.1}/portal/client_socket.py +16 -8
  6. {portal-3.0.0 → portal-3.1.1}/portal/contextlib.py +7 -7
  7. {portal-3.0.0 → portal-3.1.1}/portal/server_socket.py +11 -6
  8. {portal-3.0.0 → portal-3.1.1/portal.egg-info}/PKG-INFO +3 -3
  9. {portal-3.0.0 → portal-3.1.1}/LICENSE +0 -0
  10. {portal-3.0.0 → portal-3.1.1}/MANIFEST.in +0 -0
  11. {portal-3.0.0 → portal-3.1.1}/portal/batching.py +0 -0
  12. {portal-3.0.0 → portal-3.1.1}/portal/buffers.py +0 -0
  13. {portal-3.0.0 → portal-3.1.1}/portal/packlib.py +0 -0
  14. {portal-3.0.0 → portal-3.1.1}/portal/poollib.py +0 -0
  15. {portal-3.0.0 → portal-3.1.1}/portal/process.py +0 -0
  16. {portal-3.0.0 → portal-3.1.1}/portal/server.py +0 -0
  17. {portal-3.0.0 → portal-3.1.1}/portal/sharray.py +0 -0
  18. {portal-3.0.0 → portal-3.1.1}/portal/thread.py +0 -0
  19. {portal-3.0.0 → portal-3.1.1}/portal/utils.py +0 -0
  20. {portal-3.0.0 → portal-3.1.1}/portal.egg-info/SOURCES.txt +0 -0
  21. {portal-3.0.0 → portal-3.1.1}/portal.egg-info/dependency_links.txt +0 -0
  22. {portal-3.0.0 → portal-3.1.1}/portal.egg-info/requires.txt +0 -0
  23. {portal-3.0.0 → portal-3.1.1}/portal.egg-info/top_level.txt +0 -0
  24. {portal-3.0.0 → portal-3.1.1}/pyproject.toml +0 -0
  25. {portal-3.0.0 → portal-3.1.1}/requirements.txt +0 -0
  26. {portal-3.0.0 → portal-3.1.1}/setup.cfg +0 -0
  27. {portal-3.0.0 → portal-3.1.1}/setup.py +0 -0
  28. {portal-3.0.0 → portal-3.1.1}/tests/test_batching.py +0 -0
  29. {portal-3.0.0 → portal-3.1.1}/tests/test_client.py +0 -0
  30. {portal-3.0.0 → portal-3.1.1}/tests/test_errfile.py +0 -0
  31. {portal-3.0.0 → portal-3.1.1}/tests/test_pack.py +0 -0
  32. {portal-3.0.0 → portal-3.1.1}/tests/test_process.py +0 -0
  33. {portal-3.0.0 → portal-3.1.1}/tests/test_server.py +0 -0
  34. {portal-3.0.0 → portal-3.1.1}/tests/test_socket.py +0 -0
  35. {portal-3.0.0 → portal-3.1.1}/tests/test_thread.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: portal
3
- Version: 3.0.0
3
+ Version: 3.1.1
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 a `Client`. Wait on results via `Future` objects. Clients can
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 a `Client`. Wait on results via `Future` objects. Clients can
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
@@ -1,4 +1,4 @@
1
- __version__ = '3.0.0'
1
+ __version__ = '3.1.1'
2
2
 
3
3
  import multiprocessing as mp
4
4
  try:
@@ -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:
@@ -184,13 +186,15 @@ class ClientSocket:
184
186
  sock.settimeout(0)
185
187
  self._log('Connection established')
186
188
  return sock
189
+ except TimeoutError as e:
190
+ error = e
187
191
  except ConnectionError as e:
188
- self._log(f'Connection error ({e})')
189
- time.sleep(0.1)
190
- except TimeoutError:
191
- pass
192
+ error = e
193
+ except socket.gaierror as e:
194
+ error = e
195
+ time.sleep(0.1)
192
196
  if once:
193
- self._log('Still trying to connect...')
197
+ self._log(f'Still trying to connect... ({error})')
194
198
  once = False
195
199
  sock.close()
196
200
  return None
@@ -221,7 +225,11 @@ class ClientSocket:
221
225
  return sock, addr
222
226
 
223
227
  def _log(self, *args):
224
- if self.options.logging:
225
- style = utils.style(color='yellow', bold=True)
228
+ if not self.options.logging:
229
+ return
230
+ if self.options.logging_color:
231
+ style = utils.style(color=self.options.logging_color)
226
232
  reset = utils.style(reset=True)
227
- print(style + f'[{self.name}]', *args, reset)
233
+ else:
234
+ style, reset = '', ''
235
+ print(style + f'[{self.name}]' + reset, *args)
@@ -44,7 +44,7 @@ class Context:
44
44
  initfns=None,
45
45
  clientkw=None,
46
46
  serverkw=None,
47
- hostname=None,
47
+ host=None,
48
48
  ipv6=None,
49
49
  ):
50
50
 
@@ -77,8 +77,8 @@ class Context:
77
77
  assert isinstance(serverkw, dict)
78
78
  self.serverkw = serverkw
79
79
 
80
- if hostname is not None:
81
- self.serverkw['hostname'] = hostname
80
+ if host is not None:
81
+ self.serverkw['host'] = host
82
82
 
83
83
  if ipv6 is not None:
84
84
  self.clientkw['ipv6'] = ipv6
@@ -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):
@@ -26,11 +26,12 @@ class Connection:
26
26
  class Options:
27
27
 
28
28
  ipv6: bool = False
29
- hostname: str = ''
29
+ host: str = ''
30
30
  max_msg_size: int = 4 * 1024 ** 3
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:
@@ -42,10 +43,10 @@ class ServerSocket:
42
43
  self.options = Options(**{**contextlib.context.serverkw, **kwargs})
43
44
  if self.options.ipv6:
44
45
  self.sock = socket.socket(socket.AF_INET6, socket.SOCK_STREAM)
45
- self.addr = (self.options.hostname, port, 0, 0)
46
+ self.addr = (self.options.host, port, 0, 0)
46
47
  else:
47
48
  self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
48
- self.addr = (self.options.hostname, port)
49
+ self.addr = (self.options.host, port)
49
50
  self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
50
51
  self.sock.bind(self.addr)
51
52
  self.sock.setblocking(False)
@@ -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
- style = utils.style(color='blue', bold=True)
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
- print(style + f'[{self.name}]', *args, reset)
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.0.0
3
+ Version: 3.1.1
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 a `Client`. Wait on results via `Future` objects. Clients can
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