portal 3.1.4__tar.gz → 3.1.6__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.1.4/portal.egg-info → portal-3.1.6}/PKG-INFO +1 -1
  2. {portal-3.1.4 → portal-3.1.6}/portal/__init__.py +1 -1
  3. {portal-3.1.4 → portal-3.1.6}/portal/client.py +6 -6
  4. {portal-3.1.4 → portal-3.1.6}/portal/client_socket.py +5 -10
  5. {portal-3.1.4 → portal-3.1.6}/portal/contextlib.py +1 -0
  6. {portal-3.1.4 → portal-3.1.6}/portal/server_socket.py +1 -0
  7. {portal-3.1.4 → portal-3.1.6/portal.egg-info}/PKG-INFO +1 -1
  8. {portal-3.1.4 → portal-3.1.6}/LICENSE +0 -0
  9. {portal-3.1.4 → portal-3.1.6}/MANIFEST.in +0 -0
  10. {portal-3.1.4 → portal-3.1.6}/README.md +0 -0
  11. {portal-3.1.4 → portal-3.1.6}/portal/batching.py +0 -0
  12. {portal-3.1.4 → portal-3.1.6}/portal/buffers.py +0 -0
  13. {portal-3.1.4 → portal-3.1.6}/portal/packlib.py +0 -0
  14. {portal-3.1.4 → portal-3.1.6}/portal/poollib.py +0 -0
  15. {portal-3.1.4 → portal-3.1.6}/portal/process.py +0 -0
  16. {portal-3.1.4 → portal-3.1.6}/portal/server.py +0 -0
  17. {portal-3.1.4 → portal-3.1.6}/portal/sharray.py +0 -0
  18. {portal-3.1.4 → portal-3.1.6}/portal/thread.py +0 -0
  19. {portal-3.1.4 → portal-3.1.6}/portal/utils.py +0 -0
  20. {portal-3.1.4 → portal-3.1.6}/portal.egg-info/SOURCES.txt +0 -0
  21. {portal-3.1.4 → portal-3.1.6}/portal.egg-info/dependency_links.txt +0 -0
  22. {portal-3.1.4 → portal-3.1.6}/portal.egg-info/requires.txt +0 -0
  23. {portal-3.1.4 → portal-3.1.6}/portal.egg-info/top_level.txt +0 -0
  24. {portal-3.1.4 → portal-3.1.6}/pyproject.toml +0 -0
  25. {portal-3.1.4 → portal-3.1.6}/requirements.txt +0 -0
  26. {portal-3.1.4 → portal-3.1.6}/setup.cfg +0 -0
  27. {portal-3.1.4 → portal-3.1.6}/setup.py +0 -0
  28. {portal-3.1.4 → portal-3.1.6}/tests/test_batching.py +0 -0
  29. {portal-3.1.4 → portal-3.1.6}/tests/test_client.py +0 -0
  30. {portal-3.1.4 → portal-3.1.6}/tests/test_errfile.py +0 -0
  31. {portal-3.1.4 → portal-3.1.6}/tests/test_pack.py +0 -0
  32. {portal-3.1.4 → portal-3.1.6}/tests/test_process.py +0 -0
  33. {portal-3.1.4 → portal-3.1.6}/tests/test_server.py +0 -0
  34. {portal-3.1.4 → portal-3.1.6}/tests/test_socket.py +0 -0
  35. {portal-3.1.4 → portal-3.1.6}/tests/test_thread.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: portal
3
- Version: 3.1.4
3
+ Version: 3.1.6
4
4
  Summary: Fast and reliable distributed systems in Python
5
5
  Home-page: http://github.com/danijar/portal
6
6
  Author: Danijar Hafner
@@ -1,4 +1,4 @@
1
- __version__ = '3.1.4'
1
+ __version__ = '3.1.6'
2
2
 
3
3
  import multiprocessing as mp
4
4
  try:
@@ -98,17 +98,17 @@ class Client:
98
98
  reqnum = bytes(data[:8])
99
99
  status = int.from_bytes(data[8:16], 'little', signed=False)
100
100
  future = self.futures.pop(reqnum, None)
101
- assert future, (
102
- f'Unexpected request number: {reqnum}',
103
- sorted(self.futures.keys()))
104
- if status == 0:
101
+ if not future:
102
+ existing = sorted(self.futures.keys())
103
+ print(f'Unexpected request number: {reqnum}', existing)
104
+ elif status == 0:
105
105
  data = packlib.unpack(data[16:])
106
106
  future.set_result(data)
107
+ with self.cond: self.cond.notify_all()
107
108
  else:
108
109
  message = bytes(data[16:]).decode('utf-8')
109
110
  self._seterr(future, RuntimeError(message))
110
- with self.cond:
111
- self.cond.notify_all()
111
+ with self.cond: self.cond.notify_all()
112
112
  self.socket.recv()
113
113
 
114
114
  def _disc(self):
@@ -1,7 +1,7 @@
1
1
  import collections
2
2
  import dataclasses
3
3
  import queue
4
- import selectors
4
+ import select
5
5
  import socket
6
6
  import sys
7
7
  import threading
@@ -109,7 +109,6 @@ class ClientSocket:
109
109
 
110
110
  def _loop(self):
111
111
  recvbuf = buffers.RecvBuffer(maxsize=self.options.max_msg_size)
112
- sel = selectors.DefaultSelector()
113
112
  sock = None
114
113
  isconn = False # Local mirror of self.isconn without the lock.
115
114
 
@@ -121,7 +120,6 @@ class ClientSocket:
121
120
  sock = self._connect()
122
121
  if not sock:
123
122
  break
124
- sel.register(sock, selectors.EVENT_READ | selectors.EVENT_WRITE)
125
123
  self.isconn.set()
126
124
  isconn = True
127
125
  if not self.options.autoconn:
@@ -130,12 +128,9 @@ class ClientSocket:
130
128
 
131
129
  try:
132
130
 
133
- ready = sel.select(timeout=0.2)
134
- if not ready:
135
- continue
136
- _, mask = ready[0]
131
+ readable, writable, _ = select.select([sock], [sock], [], 0.2)
137
132
 
138
- if mask & selectors.EVENT_READ:
133
+ if readable:
139
134
  try:
140
135
  recvbuf.recv(sock)
141
136
  if recvbuf.done():
@@ -148,7 +143,7 @@ class ClientSocket:
148
143
  except BlockingIOError:
149
144
  pass
150
145
 
151
- if self.sendq and mask & selectors.EVENT_WRITE:
146
+ if self.sendq and writable:
152
147
  try:
153
148
  self.sendq[0].send(sock)
154
149
  if self.sendq[0].done():
@@ -162,7 +157,6 @@ class ClientSocket:
162
157
  self._log(f'Connection to server lost ({detail})')
163
158
  self.isconn.clear()
164
159
  isconn = False
165
- sel.unregister(sock)
166
160
  sock.close()
167
161
  # Clear message queue on disconnect. There is no meaningful concept of
168
162
  # sucessful delivery of a message at this level. For example, the
@@ -213,6 +207,7 @@ class ClientSocket:
213
207
  else:
214
208
  sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
215
209
  addr = self.addr
210
+ # sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
216
211
  after = self.options.keepalive_after
217
212
  every = self.options.keepalive_every
218
213
  fails = self.options.keepalive_fails
@@ -147,6 +147,7 @@ class Context:
147
147
  if self.errfile and self.errfile.exists():
148
148
  print(f'Shutting down due to error file: {self.errfile}')
149
149
  self.shutdown(2)
150
+ break
150
151
  if self.done.wait(self.interval):
151
152
  break
152
153
 
@@ -47,6 +47,7 @@ class ServerSocket:
47
47
  self.sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
48
48
  self.addr = (self.options.host, port)
49
49
  self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
50
+ # self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
50
51
  self.sock.bind(self.addr)
51
52
  self.sock.setblocking(False)
52
53
  self.sock.listen()
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: portal
3
- Version: 3.1.4
3
+ Version: 3.1.6
4
4
  Summary: Fast and reliable distributed systems in Python
5
5
  Home-page: http://github.com/danijar/portal
6
6
  Author: Danijar Hafner
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