portal 3.1.10__tar.gz → 3.1.12__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.1.10/portal.egg-info → portal-3.1.12}/PKG-INFO +1 -1
- {portal-3.1.10 → portal-3.1.12}/portal/__init__.py +1 -1
- {portal-3.1.10 → portal-3.1.12}/portal/batching.py +1 -0
- {portal-3.1.10 → portal-3.1.12}/portal/contextlib.py +11 -0
- {portal-3.1.10 → portal-3.1.12}/portal/server_socket.py +1 -0
- {portal-3.1.10 → portal-3.1.12}/portal/utils.py +6 -6
- {portal-3.1.10 → portal-3.1.12/portal.egg-info}/PKG-INFO +1 -1
- {portal-3.1.10 → portal-3.1.12}/LICENSE +0 -0
- {portal-3.1.10 → portal-3.1.12}/MANIFEST.in +0 -0
- {portal-3.1.10 → portal-3.1.12}/README.md +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/buffers.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/client.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/client_socket.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/packlib.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/poollib.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/process.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/server.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/sharray.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal/thread.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal.egg-info/SOURCES.txt +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal.egg-info/dependency_links.txt +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal.egg-info/requires.txt +0 -0
- {portal-3.1.10 → portal-3.1.12}/portal.egg-info/top_level.txt +0 -0
- {portal-3.1.10 → portal-3.1.12}/pyproject.toml +0 -0
- {portal-3.1.10 → portal-3.1.12}/requirements.txt +0 -0
- {portal-3.1.10 → portal-3.1.12}/setup.cfg +0 -0
- {portal-3.1.10 → portal-3.1.12}/setup.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/tests/test_batching.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/tests/test_client.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/tests/test_errfile.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/tests/test_pack.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/tests/test_process.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/tests/test_server.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/tests/test_socket.py +0 -0
- {portal-3.1.10 → portal-3.1.12}/tests/test_thread.py +0 -0
@@ -19,6 +19,7 @@ class BatchServer:
|
|
19
19
|
self, port, name='Server', workers=1, errors=True,
|
20
20
|
process=True, shmem=False, **kwargs):
|
21
21
|
inner_port = utils.free_port()
|
22
|
+
assert port != inner_port, (port, inner_port)
|
22
23
|
self.name = name
|
23
24
|
self.server = server.Server(inner_port, name, workers, errors, **kwargs)
|
24
25
|
if process:
|
@@ -61,6 +61,7 @@ class Context:
|
|
61
61
|
assert hasattr(errfile, 'exists') and hasattr(errfile, 'write_text')
|
62
62
|
self.errfile = errfile
|
63
63
|
self._check_errfile()
|
64
|
+
self._install_excepthook()
|
64
65
|
|
65
66
|
if interval:
|
66
67
|
assert isinstance(interval, (int, float))
|
@@ -148,6 +149,16 @@ class Context:
|
|
148
149
|
while not self.done.wait(self.interval):
|
149
150
|
self._check_errfile()
|
150
151
|
|
152
|
+
def _install_excepthook(self):
|
153
|
+
existing = sys.excepthook
|
154
|
+
def patched(typ, val, tb):
|
155
|
+
if self.errfile:
|
156
|
+
message = ''.join(traceback.format_exception(typ, val, tb)).strip('\n')
|
157
|
+
self.errfile.write_text(message)
|
158
|
+
print(f'Wrote errorfile: {self.errfile}', file=sys.stderr)
|
159
|
+
return existing(typ, val, tb)
|
160
|
+
sys.excepthook = patched
|
161
|
+
|
151
162
|
def _check_errfile(self):
|
152
163
|
if self.errfile and self.errfile.exists():
|
153
164
|
message = f'Shutting down due to error file: {self.errfile}'
|
@@ -48,6 +48,7 @@ class ServerSocket:
|
|
48
48
|
self.addr = (self.options.host, port)
|
49
49
|
self.sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
50
50
|
# self.sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_NODELAY, 1)
|
51
|
+
self._log(f'Binding to {self.addr[0]}:{self.addr[1]}')
|
51
52
|
self.sock.bind(self.addr)
|
52
53
|
self.sock.setblocking(False)
|
53
54
|
self.sock.listen()
|
@@ -82,12 +82,12 @@ def free_port():
|
|
82
82
|
# Return a port that is currently free. This function is not thread or
|
83
83
|
# process safe, because there is no way to guarantee that the port will still
|
84
84
|
# be free at the time it will be used.
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
85
|
+
sock = socket.socket()
|
86
|
+
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
87
|
+
sock.bind(('localhost', 0))
|
88
|
+
port = sock.getsockname()[1]
|
89
|
+
sock.close()
|
90
|
+
return port
|
91
91
|
|
92
92
|
|
93
93
|
def style(color=None, background=None, bold=None, underline=None, reset=None):
|
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
|