portal 3.1.7__tar.gz → 3.1.9__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.7/portal.egg-info → portal-3.1.9}/PKG-INFO +1 -1
- {portal-3.1.7 → portal-3.1.9}/portal/__init__.py +1 -1
- {portal-3.1.7 → portal-3.1.9}/portal/client.py +6 -21
- {portal-3.1.7 → portal-3.1.9}/portal/contextlib.py +9 -8
- {portal-3.1.7 → portal-3.1.9/portal.egg-info}/PKG-INFO +1 -1
- {portal-3.1.7 → portal-3.1.9}/tests/test_errfile.py +10 -11
- {portal-3.1.7 → portal-3.1.9}/LICENSE +0 -0
- {portal-3.1.7 → portal-3.1.9}/MANIFEST.in +0 -0
- {portal-3.1.7 → portal-3.1.9}/README.md +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/batching.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/buffers.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/client_socket.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/packlib.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/poollib.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/process.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/server.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/server_socket.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/sharray.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/thread.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal/utils.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal.egg-info/SOURCES.txt +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal.egg-info/dependency_links.txt +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal.egg-info/requires.txt +0 -0
- {portal-3.1.7 → portal-3.1.9}/portal.egg-info/top_level.txt +0 -0
- {portal-3.1.7 → portal-3.1.9}/pyproject.toml +0 -0
- {portal-3.1.7 → portal-3.1.9}/requirements.txt +0 -0
- {portal-3.1.7 → portal-3.1.9}/setup.cfg +0 -0
- {portal-3.1.7 → portal-3.1.9}/setup.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/tests/test_batching.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/tests/test_client.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/tests/test_pack.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/tests/test_process.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/tests/test_server.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/tests/test_socket.py +0 -0
- {portal-3.1.7 → portal-3.1.9}/tests/test_thread.py +0 -0
@@ -106,34 +106,19 @@ class Client:
|
|
106
106
|
reqnum = bytes(data[:8])
|
107
107
|
status = int.from_bytes(data[8:16], 'little', signed=False)
|
108
108
|
future = self.futures.pop(reqnum, None)
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
if status == 0:
|
109
|
+
if not future:
|
110
|
+
existing = sorted(self.futures.keys())
|
111
|
+
print(f'Unexpected request number: {reqnum}', existing)
|
112
|
+
elif status == 0:
|
115
113
|
data = packlib.unpack(data[16:])
|
116
114
|
future.set_result(data)
|
115
|
+
with self.cond: self.cond.notify_all()
|
117
116
|
else:
|
118
117
|
message = bytes(data[16:]).decode('utf-8')
|
119
118
|
self._seterr(future, RuntimeError(message))
|
120
|
-
|
121
|
-
self.cond.notify_all()
|
119
|
+
with self.cond: self.cond.notify_all()
|
122
120
|
self.socket.recv()
|
123
121
|
|
124
|
-
# if not future:
|
125
|
-
# existing = sorted(self.futures.keys())
|
126
|
-
# print(f'Unexpected request number: {reqnum}', existing)
|
127
|
-
# elif status == 0:
|
128
|
-
# data = packlib.unpack(data[16:])
|
129
|
-
# future.set_result(data)
|
130
|
-
# with self.cond: self.cond.notify_all()
|
131
|
-
# else:
|
132
|
-
# message = bytes(data[16:]).decode('utf-8')
|
133
|
-
# self._seterr(future, RuntimeError(message))
|
134
|
-
# with self.cond: self.cond.notify_all()
|
135
|
-
# self.socket.recv()
|
136
|
-
|
137
122
|
def _disc(self):
|
138
123
|
if self.socket.options.autoconn:
|
139
124
|
for future in list(self.futures.values()):
|
@@ -60,6 +60,7 @@ class Context:
|
|
60
60
|
errfile = pathlib.Path(errfile)
|
61
61
|
assert hasattr(errfile, 'exists') and hasattr(errfile, 'write_text')
|
62
62
|
self.errfile = errfile
|
63
|
+
self._check_errfile()
|
63
64
|
|
64
65
|
if interval:
|
65
66
|
assert isinstance(interval, (int, float))
|
@@ -144,14 +145,14 @@ class Context:
|
|
144
145
|
return self.children[ident]
|
145
146
|
|
146
147
|
def _watcher(self):
|
147
|
-
while
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
148
|
+
while not self.done.wait(self.interval):
|
149
|
+
self._check_errfile()
|
150
|
+
|
151
|
+
def _check_errfile(self):
|
152
|
+
if self.errfile and self.errfile.exists():
|
153
|
+
message = f'Shutting down due to error file: {self.errfile}'
|
154
|
+
print(message, file=sys.stderr)
|
155
|
+
self.shutdown(exitcode=2)
|
155
156
|
|
156
157
|
|
157
158
|
context = Context()
|
@@ -24,31 +24,30 @@ class TestErrfile:
|
|
24
24
|
assert 'line' in content
|
25
25
|
assert 'in fn' in content
|
26
26
|
|
27
|
-
@pytest.mark.parametrize('repeat', range(
|
27
|
+
@pytest.mark.parametrize('repeat', range(5))
|
28
28
|
def test_sibling_procs(self, tmpdir, repeat):
|
29
29
|
errfile = pathlib.Path(tmpdir) / 'error'
|
30
|
-
|
30
|
+
barrier = portal.context.mp.Barrier(3)
|
31
31
|
|
32
|
-
def fn1(
|
32
|
+
def fn1(barrier, errfile):
|
33
33
|
portal.setup(errfile=errfile, interval=0.1)
|
34
|
-
|
34
|
+
barrier.wait()
|
35
35
|
raise ValueError('reason')
|
36
36
|
|
37
|
-
def fn2(
|
37
|
+
def fn2(barrier, errfile):
|
38
38
|
portal.setup(errfile=errfile, interval=0.1)
|
39
|
-
|
39
|
+
barrier.wait()
|
40
40
|
while True:
|
41
41
|
time.sleep(0.1)
|
42
42
|
|
43
|
-
worker1 = portal.Process(fn1,
|
44
|
-
worker2 = portal.Process(fn2,
|
45
|
-
|
46
|
-
ready.acquire()
|
43
|
+
worker1 = portal.Process(fn1, barrier, errfile, start=True)
|
44
|
+
worker2 = portal.Process(fn2, barrier, errfile, start=True)
|
45
|
+
barrier.wait()
|
47
46
|
worker1.join()
|
48
47
|
worker2.join()
|
49
48
|
content = errfile.read_text()
|
50
49
|
first_line = content.split('\n')[0]
|
51
|
-
assert "Error in '
|
50
|
+
assert "Error in 'fn1' (ValueError: reason):" == first_line
|
52
51
|
assert not worker1.running
|
53
52
|
assert not worker2.running
|
54
53
|
assert worker1.exitcode == 1
|
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
|