pyglove 0.4.5.dev202501230809__py3-none-any.whl → 0.4.5.dev202501240809__py3-none-any.whl
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.
- pyglove/core/coding/execution.py +16 -13
- {pyglove-0.4.5.dev202501230809.dist-info → pyglove-0.4.5.dev202501240809.dist-info}/METADATA +1 -1
- {pyglove-0.4.5.dev202501230809.dist-info → pyglove-0.4.5.dev202501240809.dist-info}/RECORD +6 -6
- {pyglove-0.4.5.dev202501230809.dist-info → pyglove-0.4.5.dev202501240809.dist-info}/LICENSE +0 -0
- {pyglove-0.4.5.dev202501230809.dist-info → pyglove-0.4.5.dev202501240809.dist-info}/WHEEL +0 -0
- {pyglove-0.4.5.dev202501230809.dist-info → pyglove-0.4.5.dev202501240809.dist-info}/top_level.txt +0 -0
pyglove/core/coding/execution.py
CHANGED
@@ -18,6 +18,7 @@ import contextlib
|
|
18
18
|
import io
|
19
19
|
import multiprocessing
|
20
20
|
import pickle
|
21
|
+
import queue
|
21
22
|
from typing import Any, Callable, Dict, Optional, Union
|
22
23
|
|
23
24
|
from pyglove.core import utils
|
@@ -197,28 +198,30 @@ def sandbox_call(
|
|
197
198
|
q.put(e)
|
198
199
|
|
199
200
|
q = multiprocessing.Queue()
|
201
|
+
p = multiprocessing.Process(
|
202
|
+
target=_call, args=tuple([q] + list(args)), kwargs=kwargs
|
203
|
+
)
|
200
204
|
try:
|
201
|
-
p = multiprocessing.Process(
|
202
|
-
target=_call, args=tuple([q] + list(args)), kwargs=kwargs)
|
203
205
|
p.start()
|
204
|
-
|
206
|
+
x = q.get(timeout=timeout)
|
207
|
+
except queue.Empty as e:
|
205
208
|
if p.is_alive():
|
206
209
|
# We use `kill` instead of `terminate` to release process resources
|
207
210
|
# right away.
|
208
211
|
p.kill()
|
209
|
-
|
210
|
-
x = q.get()
|
211
|
-
if isinstance(x, Exception):
|
212
|
-
raise x
|
213
|
-
try:
|
214
|
-
return pickle.loads(x)
|
215
|
-
except Exception as e:
|
216
|
-
raise errors.SerializationError(
|
217
|
-
'Cannot deserialize the output from sandbox.', e
|
218
|
-
) from e
|
212
|
+
raise TimeoutError(f'Execution time exceed {timeout} seconds.') from e
|
219
213
|
finally:
|
220
214
|
q.close()
|
221
215
|
|
216
|
+
if isinstance(x, Exception):
|
217
|
+
raise x
|
218
|
+
try:
|
219
|
+
return pickle.loads(x)
|
220
|
+
except Exception as e:
|
221
|
+
raise errors.SerializationError(
|
222
|
+
'Cannot deserialize the output from sandbox.', e
|
223
|
+
) from e
|
224
|
+
|
222
225
|
|
223
226
|
def maybe_sandbox_call(
|
224
227
|
func: Callable[..., Any],
|
@@ -5,7 +5,7 @@ pyglove/core/logging_test.py,sha256=3z_c6wnxbqDbwUmSOAZzeDPXvzoweYL5QHUQVMJ5Xgo,
|
|
5
5
|
pyglove/core/coding/__init__.py,sha256=tuHIg19ZchtkOQbdFVTVLkUpBa5f1eo66XtnKw3lcIU,1645
|
6
6
|
pyglove/core/coding/errors.py,sha256=vstDb52lk5uJef2k_0_1dqvGv8eDYNq37IrqjGJ-cNc,3302
|
7
7
|
pyglove/core/coding/errors_test.py,sha256=fwOR8vLiRvLadubsccyE19hLHj-kThlCQt88qmUYk9M,2311
|
8
|
-
pyglove/core/coding/execution.py,sha256=
|
8
|
+
pyglove/core/coding/execution.py,sha256=Rq-rFPkecd70-wLnK-51L_rK01nd3J5SKfQidg3_qvY,10883
|
9
9
|
pyglove/core/coding/execution_test.py,sha256=vTMLOCs7ceVi-XEz7-0CdPeoKqswBUQ26SzTqthcU4c,8397
|
10
10
|
pyglove/core/coding/function_generation.py,sha256=2fCqcdcizVYtGYE6QGpw5m1kuH9Fp0OF4BjyJ4en6tw,1636
|
11
11
|
pyglove/core/coding/function_generation_test.py,sha256=kbSwmZF8Vog0R0OTSpuzPblEbMLoRJ1TigeIrwDhHS8,2161
|
@@ -211,8 +211,8 @@ pyglove/ext/scalars/randoms.py,sha256=LkMIIx7lOq_lvJvVS3BrgWGuWl7Pi91-lA-O8x_gZs
|
|
211
211
|
pyglove/ext/scalars/randoms_test.py,sha256=nEhiqarg8l_5EOucp59CYrpO2uKxS1pe0hmBdZUzRNM,2000
|
212
212
|
pyglove/ext/scalars/step_wise.py,sha256=IDw3tuTpv0KVh7AN44W43zqm1-E0HWPUlytWOQC9w3Y,3789
|
213
213
|
pyglove/ext/scalars/step_wise_test.py,sha256=TL1vJ19xVx2t5HKuyIzGoogF7N3Rm8YhLE6JF7i0iy8,2540
|
214
|
-
pyglove-0.4.5.
|
215
|
-
pyglove-0.4.5.
|
216
|
-
pyglove-0.4.5.
|
217
|
-
pyglove-0.4.5.
|
218
|
-
pyglove-0.4.5.
|
214
|
+
pyglove-0.4.5.dev202501240809.dist-info/LICENSE,sha256=WNHhf_5RCaeuKWyq_K39vmp9F28LxKsB4SpomwSZ2L0,11357
|
215
|
+
pyglove-0.4.5.dev202501240809.dist-info/METADATA,sha256=lR9fscbdN1TlKb9vFXFRp2IyaPixC2Zl4E9iNCC87SE,7067
|
216
|
+
pyglove-0.4.5.dev202501240809.dist-info/WHEEL,sha256=In9FTNxeP60KnTkGw7wk6mJPYd_dQSjEZmXdBdMCI-8,91
|
217
|
+
pyglove-0.4.5.dev202501240809.dist-info/top_level.txt,sha256=wITzJSKcj8GZUkbq-MvUQnFadkiuAv_qv5qQMw0fIow,8
|
218
|
+
pyglove-0.4.5.dev202501240809.dist-info/RECORD,,
|
File without changes
|
File without changes
|
{pyglove-0.4.5.dev202501230809.dist-info → pyglove-0.4.5.dev202501240809.dist-info}/top_level.txt
RENAMED
File without changes
|