portal 3.4.3__tar.gz → 3.4.4__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.4.3/portal.egg-info → portal-3.4.4}/PKG-INFO +1 -1
- {portal-3.4.3 → portal-3.4.4}/portal/__init__.py +1 -1
- {portal-3.4.3 → portal-3.4.4}/portal/client_socket.py +30 -30
- {portal-3.4.3 → portal-3.4.4}/portal/server_socket.py +7 -5
- {portal-3.4.3 → portal-3.4.4/portal.egg-info}/PKG-INFO +1 -1
- {portal-3.4.3 → portal-3.4.4}/LICENSE +0 -0
- {portal-3.4.3 → portal-3.4.4}/MANIFEST.in +0 -0
- {portal-3.4.3 → portal-3.4.4}/README.md +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/batching.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/buffers.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/client.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/contextlib.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/packlib.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/poollib.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/process.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/server.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/sharray.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/thread.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal/utils.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal.egg-info/SOURCES.txt +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal.egg-info/dependency_links.txt +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal.egg-info/requires.txt +0 -0
- {portal-3.4.3 → portal-3.4.4}/portal.egg-info/top_level.txt +0 -0
- {portal-3.4.3 → portal-3.4.4}/pyproject.toml +0 -0
- {portal-3.4.3 → portal-3.4.4}/requirements.txt +0 -0
- {portal-3.4.3 → portal-3.4.4}/setup.cfg +0 -0
- {portal-3.4.3 → portal-3.4.4}/setup.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/tests/test_batching.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/tests/test_client.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/tests/test_errfile.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/tests/test_pack.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/tests/test_process.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/tests/test_server.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/tests/test_socket.py +0 -0
- {portal-3.4.3 → portal-3.4.4}/tests/test_thread.py +0 -0
@@ -30,7 +30,7 @@ class Options:
|
|
30
30
|
logging: bool = True
|
31
31
|
logging_color: str = 'yellow'
|
32
32
|
connect_wait: float = 0.1
|
33
|
-
|
33
|
+
idle_sleep: float = 0.0001
|
34
34
|
|
35
35
|
|
36
36
|
class ClientSocket:
|
@@ -130,33 +130,36 @@ class ClientSocket:
|
|
130
130
|
|
131
131
|
try:
|
132
132
|
|
133
|
-
|
134
|
-
# polling. Is there a way to avoid that?
|
133
|
+
idle = True
|
135
134
|
pairs = poll.poll(0.2)
|
136
|
-
if
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
self.sendq.
|
158
|
-
|
159
|
-
|
135
|
+
if pairs:
|
136
|
+
_, mask = pairs[0]
|
137
|
+
|
138
|
+
if mask & select.POLLIN:
|
139
|
+
try:
|
140
|
+
recvbuf.recv(sock)
|
141
|
+
idle = False
|
142
|
+
if recvbuf.done():
|
143
|
+
if self.recvq.qsize() > self.options.max_recv_queue:
|
144
|
+
raise RuntimeError('Too many incoming messages enqueued')
|
145
|
+
msg = recvbuf.result()
|
146
|
+
self.recvq.put(msg)
|
147
|
+
[x(msg) for x in self.callbacks_recv]
|
148
|
+
recvbuf = buffers.RecvBuffer(maxsize=self.options.max_msg_size)
|
149
|
+
except BlockingIOError:
|
150
|
+
pass
|
151
|
+
|
152
|
+
if self.sendq and mask & select.POLLOUT:
|
153
|
+
try:
|
154
|
+
self.sendq[0].send(sock)
|
155
|
+
idle = False
|
156
|
+
if self.sendq[0].done():
|
157
|
+
self.sendq.popleft()
|
158
|
+
except BlockingIOError:
|
159
|
+
pass
|
160
|
+
|
161
|
+
if idle and self.options.idle_sleep:
|
162
|
+
time.sleep(self.options.idle_sleep)
|
160
163
|
|
161
164
|
except OSError as e:
|
162
165
|
detail = f'{type(e).__name__}'
|
@@ -176,9 +179,6 @@ class ClientSocket:
|
|
176
179
|
[x() for x in self.callbacks_disc]
|
177
180
|
continue
|
178
181
|
|
179
|
-
if self.options.loop_sleep:
|
180
|
-
time.sleep(self.options.loop_sleep)
|
181
|
-
|
182
182
|
if sock:
|
183
183
|
sock.close()
|
184
184
|
|
@@ -32,7 +32,7 @@ class Options:
|
|
32
32
|
max_send_queue: int = 4096
|
33
33
|
logging: bool = True
|
34
34
|
logging_color: str = 'blue'
|
35
|
-
|
35
|
+
idle_sleep: float = 0.0001
|
36
36
|
|
37
37
|
|
38
38
|
class ServerSocket:
|
@@ -105,15 +105,16 @@ class ServerSocket:
|
|
105
105
|
def _loop(self):
|
106
106
|
try:
|
107
107
|
while self.running or self._numsending():
|
108
|
+
idle = True
|
108
109
|
writeable = []
|
109
|
-
# TODO: According to the py-spy profiler, the GIL is held during
|
110
|
-
# polling. Is there a way to avoid that?
|
111
110
|
for key, mask in self.sel.select(timeout=0.2):
|
112
111
|
if key.data is None and self.reading:
|
113
112
|
assert mask & selectors.EVENT_READ
|
114
113
|
self._accept(key.fileobj)
|
114
|
+
idle = False
|
115
115
|
elif mask & selectors.EVENT_READ and self.reading:
|
116
116
|
self._recv(key.data)
|
117
|
+
idle = False
|
117
118
|
elif mask & selectors.EVENT_WRITE:
|
118
119
|
writeable.append(key.data)
|
119
120
|
for conn in writeable:
|
@@ -121,6 +122,7 @@ class ServerSocket:
|
|
121
122
|
continue
|
122
123
|
try:
|
123
124
|
conn.sendbufs[0].send(conn.sock)
|
125
|
+
idle = False
|
124
126
|
if conn.sendbufs[0].done():
|
125
127
|
conn.sendbufs.popleft()
|
126
128
|
except BlockingIOError:
|
@@ -129,8 +131,8 @@ class ServerSocket:
|
|
129
131
|
# The client is gone but we may have buffered messages left to
|
130
132
|
# read, so we keep the socket open until recv() fails.
|
131
133
|
pass
|
132
|
-
|
133
|
-
|
134
|
+
if idle and self.options.idle_sleep:
|
135
|
+
time.sleep(self.options.idle_sleep)
|
134
136
|
except Exception as e:
|
135
137
|
self.error = e
|
136
138
|
|
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
|