isolate 0.14.0__tar.gz → 0.14.2__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.
Potentially problematic release.
This version of isolate might be problematic. Click here for more details.
- {isolate-0.14.0 → isolate-0.14.2}/PKG-INFO +1 -1
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/_isolate_version.py +2 -2
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/common.py +1 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/logger.py +3 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/server.py +75 -25
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate.egg-info/PKG-INFO +1 -1
- {isolate-0.14.0 → isolate-0.14.2}/tests/test_server.py +107 -8
- {isolate-0.14.0 → isolate-0.14.2}/.github/workflows/release.yml +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/.github/workflows/test.yml +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/.gitignore +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/.pre-commit-config.yaml +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/LICENSE +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/README.md +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/pyproject.toml +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/setup.cfg +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/_version.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/_base.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/conda.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/container.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/local.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/pyenv.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/remote.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/settings.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/backends/virtualenv.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/common/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/common/timestamp.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/_local/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/_local/_base.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/_local/agent_startup.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/common.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/_base.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/agent.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/configuration.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/agent.proto +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/agent_pb2.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/agent_pb2.pyi +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/agent_pb2_grpc.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/common.proto +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/common_pb2.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/common_pb2.pyi +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/common_pb2_grpc.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/interface.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/ipc/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/ipc/_base.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/ipc/agent.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/logs.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/py.typed +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/registry.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/definitions/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/definitions/server.proto +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/definitions/server_pb2.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/definitions/server_pb2.pyi +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/definitions/server_pb2_grpc.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/health/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/health/health.proto +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/health/health_pb2.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/health/health_pb2.pyi +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/health/health_pb2_grpc.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/health_server.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate/server/interface.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate.egg-info/SOURCES.txt +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate.egg-info/dependency_links.txt +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate.egg-info/entry_points.txt +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate.egg-info/requires.txt +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/src/isolate.egg-info/top_level.txt +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/__init__.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/conftest.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/test_backends.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/test_concurrency.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/test_connections.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/test_isolate.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/test_log.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/test_logger.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tests/test_serialization.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tools/Dockerfile +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tools/agent_requirements.txt +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tools/protobuf-requirements.txt +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tools/regen_grpc.py +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tools/requirements.txt +0 -0
- {isolate-0.14.0 → isolate-0.14.2}/tools/test_agent_requirements.txt +0 -0
|
@@ -9,6 +9,8 @@ from isolate.logs import LogLevel, LogSource
|
|
|
9
9
|
# but it handling `source` would be not trivial, so we are better off
|
|
10
10
|
# just keeping it simple for now.
|
|
11
11
|
class IsolateLogger:
|
|
12
|
+
extra_labels: Dict[str, str] = {}
|
|
13
|
+
|
|
12
14
|
def __init__(self, log_labels: Dict[str, str]):
|
|
13
15
|
self.log_labels = log_labels
|
|
14
16
|
|
|
@@ -18,6 +20,7 @@ class IsolateLogger:
|
|
|
18
20
|
"level": level.name,
|
|
19
21
|
"message": message,
|
|
20
22
|
**self.log_labels,
|
|
23
|
+
**self.extra_labels,
|
|
21
24
|
}
|
|
22
25
|
print(json.dumps(record))
|
|
23
26
|
|
|
@@ -36,6 +36,7 @@ from isolate.server.health_server import HealthServicer
|
|
|
36
36
|
from isolate.server.interface import from_grpc, to_grpc
|
|
37
37
|
|
|
38
38
|
EMPTY_MESSAGE_INTERVAL = float(os.getenv("ISOLATE_EMPTY_MESSAGE_INTERVAL", "600"))
|
|
39
|
+
SKIP_EMPTY_LOGS = os.getenv("ISOLATE_SKIP_EMPTY_LOGS") == "1"
|
|
39
40
|
MAX_GRPC_WAIT_TIMEOUT = float(os.getenv("ISOLATE_MAX_GRPC_WAIT_TIMEOUT", "10.0"))
|
|
40
41
|
|
|
41
42
|
# Whether to inherit all the packages from the current environment or not.
|
|
@@ -366,9 +367,7 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
366
367
|
|
|
367
368
|
task = self.background_tasks[request.task_id]
|
|
368
369
|
|
|
369
|
-
task.logger =
|
|
370
|
-
dict(request.metadata.logger_labels)
|
|
371
|
-
)
|
|
370
|
+
task.logger.extra_labels = dict(request.metadata.logger_labels)
|
|
372
371
|
|
|
373
372
|
return definitions.SetMetadataResponse()
|
|
374
373
|
|
|
@@ -378,13 +377,19 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
378
377
|
context: ServicerContext,
|
|
379
378
|
) -> Iterator[definitions.PartialRunResult]:
|
|
380
379
|
try:
|
|
381
|
-
|
|
380
|
+
# HACK: we can support only one task at a time for Run
|
|
381
|
+
# TODO: move away from this when we use submit for env-aware tasks
|
|
382
|
+
task = RunTask(request=request)
|
|
383
|
+
self.background_tasks["RUN"] = task
|
|
384
|
+
yield from self._run_task(task)
|
|
382
385
|
except GRPCException as exc:
|
|
383
386
|
return self.abort_with_msg(
|
|
384
387
|
exc.message,
|
|
385
388
|
context,
|
|
386
389
|
code=exc.code,
|
|
387
390
|
)
|
|
391
|
+
finally:
|
|
392
|
+
self.background_tasks.pop("RUN", None)
|
|
388
393
|
|
|
389
394
|
def List(
|
|
390
395
|
self,
|
|
@@ -464,7 +469,8 @@ class IsolateServicer(definitions.IsolateServicer):
|
|
|
464
469
|
return None
|
|
465
470
|
|
|
466
471
|
def cancel_tasks(self):
|
|
467
|
-
|
|
472
|
+
tasks_copy = self.background_tasks.copy()
|
|
473
|
+
for task in tasks_copy.values():
|
|
468
474
|
task.cancel()
|
|
469
475
|
|
|
470
476
|
|
|
@@ -484,8 +490,9 @@ class LogHandler:
|
|
|
484
490
|
task: RunTask
|
|
485
491
|
|
|
486
492
|
def handle(self, log: Log) -> None:
|
|
487
|
-
|
|
488
|
-
|
|
493
|
+
if not SKIP_EMPTY_LOGS or log.message.strip():
|
|
494
|
+
self.task.logger.log(log.level, log.message, source=log.source)
|
|
495
|
+
self._add_log_to_queue(log)
|
|
489
496
|
|
|
490
497
|
def _add_log_to_queue(self, log: Log) -> None:
|
|
491
498
|
grpc_log = cast(definitions.Log, to_grpc(log))
|
|
@@ -534,6 +541,16 @@ class SingleTaskInterceptor(ServerBoundInterceptor):
|
|
|
534
541
|
"""Sets server to terminate after the first Submit/Run task."""
|
|
535
542
|
|
|
536
543
|
_done: bool = False
|
|
544
|
+
_task_id: str | None = None
|
|
545
|
+
|
|
546
|
+
def __init__(self):
|
|
547
|
+
def terminate(request: Any, context: grpc.ServicerContext) -> Any:
|
|
548
|
+
context.abort(
|
|
549
|
+
grpc.StatusCode.RESOURCE_EXHAUSTED,
|
|
550
|
+
"Server has already served one Run/Submit task.",
|
|
551
|
+
)
|
|
552
|
+
|
|
553
|
+
self._terminator = grpc.unary_unary_rpc_method_handler(terminate)
|
|
537
554
|
|
|
538
555
|
def intercept_service(self, continuation, handler_call_details):
|
|
539
556
|
handler = continuation(handler_call_details)
|
|
@@ -542,29 +559,62 @@ class SingleTaskInterceptor(ServerBoundInterceptor):
|
|
|
542
559
|
is_run = handler_call_details.method == "/Isolate/Run"
|
|
543
560
|
is_new_task = is_submit or is_run
|
|
544
561
|
|
|
545
|
-
if is_new_task
|
|
546
|
-
raise grpc.RpcError(
|
|
547
|
-
grpc.StatusCode.UNAVAILABLE,
|
|
548
|
-
"Server has already served one Run/Submit task.",
|
|
549
|
-
)
|
|
550
|
-
elif is_new_task:
|
|
551
|
-
self._done = True
|
|
552
|
-
else:
|
|
562
|
+
if not is_new_task:
|
|
553
563
|
# Let other requests like List/Cancel/etc pass through
|
|
554
|
-
return
|
|
564
|
+
return handler
|
|
565
|
+
|
|
566
|
+
if self._done:
|
|
567
|
+
# Fail the request if the server has already served or is serving
|
|
568
|
+
# a Run/Submit task.
|
|
569
|
+
return self._terminator
|
|
570
|
+
|
|
571
|
+
self._done = True
|
|
555
572
|
|
|
556
573
|
def wrapper(method_impl):
|
|
557
574
|
@functools.wraps(method_impl)
|
|
558
|
-
def _wrapper(request, context):
|
|
559
|
-
def
|
|
560
|
-
if
|
|
561
|
-
|
|
562
|
-
|
|
575
|
+
def _wrapper(request: Any, context: grpc.ServicerContext) -> Any:
|
|
576
|
+
def termination() -> None:
|
|
577
|
+
if is_run:
|
|
578
|
+
print("Stopping server since run is finished")
|
|
579
|
+
# Stop the server after the Run task is finished
|
|
580
|
+
self.server.stop(grace=0.1)
|
|
581
|
+
|
|
582
|
+
elif is_submit:
|
|
583
|
+
# Wait until the task_id is assigned
|
|
584
|
+
while self._task_id is None:
|
|
563
585
|
time.sleep(0.1)
|
|
564
|
-
self.server.stop(grace=0.1)
|
|
565
586
|
|
|
566
|
-
|
|
567
|
-
|
|
587
|
+
# Get the task from the background tasks
|
|
588
|
+
task = self.servicer.background_tasks.get(self._task_id)
|
|
589
|
+
|
|
590
|
+
if task is not None:
|
|
591
|
+
# Wait until the task future is assigned
|
|
592
|
+
tries = 0
|
|
593
|
+
while task.future is None:
|
|
594
|
+
time.sleep(0.1)
|
|
595
|
+
tries += 1
|
|
596
|
+
if tries > 100:
|
|
597
|
+
raise RuntimeError(
|
|
598
|
+
"Task future was not assigned in time."
|
|
599
|
+
)
|
|
600
|
+
|
|
601
|
+
def _stop(*args):
|
|
602
|
+
# Small sleep to make sure the cancellation is processed
|
|
603
|
+
time.sleep(0.1)
|
|
604
|
+
print("Stopping server since the task is finished")
|
|
605
|
+
self.server.stop(grace=0.1)
|
|
606
|
+
|
|
607
|
+
# Add a callback which will stop the server
|
|
608
|
+
# after the task is finished
|
|
609
|
+
task.future.add_done_callback(_stop)
|
|
610
|
+
|
|
611
|
+
context.add_callback(termination)
|
|
612
|
+
res = method_impl(request, context)
|
|
613
|
+
|
|
614
|
+
if is_submit:
|
|
615
|
+
self._task_id = cast(definitions.SubmitResponse, res).task_id
|
|
616
|
+
|
|
617
|
+
return res
|
|
568
618
|
|
|
569
619
|
return _wrapper
|
|
570
620
|
|
|
@@ -598,7 +648,7 @@ def main(argv: list[str] | None = None) -> None:
|
|
|
598
648
|
server = grpc.server(
|
|
599
649
|
futures.ThreadPoolExecutor(max_workers=options.num_workers),
|
|
600
650
|
options=get_default_options(),
|
|
601
|
-
interceptors=interceptors,
|
|
651
|
+
interceptors=interceptors, # type: ignore
|
|
602
652
|
)
|
|
603
653
|
|
|
604
654
|
for interceptor in interceptors:
|
|
@@ -5,7 +5,7 @@ from contextlib import contextmanager
|
|
|
5
5
|
from dataclasses import dataclass
|
|
6
6
|
from functools import partial
|
|
7
7
|
from pathlib import Path
|
|
8
|
-
from typing import Any, List, Optional, cast
|
|
8
|
+
from typing import Any, Iterator, List, Optional, cast
|
|
9
9
|
|
|
10
10
|
import grpc
|
|
11
11
|
import pytest
|
|
@@ -15,7 +15,12 @@ from isolate.logs import Log, LogLevel, LogSource
|
|
|
15
15
|
from isolate.server import definitions, health
|
|
16
16
|
from isolate.server.health_server import HealthServicer
|
|
17
17
|
from isolate.server.interface import from_grpc, to_serialized_object
|
|
18
|
-
from isolate.server.server import
|
|
18
|
+
from isolate.server.server import (
|
|
19
|
+
BridgeManager,
|
|
20
|
+
IsolateServicer,
|
|
21
|
+
ServerBoundInterceptor,
|
|
22
|
+
SingleTaskInterceptor,
|
|
23
|
+
)
|
|
19
24
|
|
|
20
25
|
REPO_DIR = Path(__file__).parent.parent
|
|
21
26
|
assert (
|
|
@@ -34,14 +39,32 @@ class Stubs:
|
|
|
34
39
|
health_stub: health.HealthStub
|
|
35
40
|
|
|
36
41
|
|
|
42
|
+
@pytest.fixture
|
|
43
|
+
def interceptors():
|
|
44
|
+
return []
|
|
45
|
+
|
|
46
|
+
|
|
37
47
|
@contextmanager
|
|
38
|
-
def make_server(
|
|
48
|
+
def make_server(
|
|
49
|
+
tmp_path: Path, interceptors: Optional[List[ServerBoundInterceptor]] = None
|
|
50
|
+
) -> Iterator[Stubs]:
|
|
51
|
+
interceptors = interceptors or []
|
|
39
52
|
server = grpc.server(
|
|
40
|
-
futures.ThreadPoolExecutor(max_workers=1),
|
|
53
|
+
futures.ThreadPoolExecutor(max_workers=1),
|
|
54
|
+
options=get_default_options(),
|
|
55
|
+
interceptors=interceptors, # type: ignore
|
|
41
56
|
)
|
|
57
|
+
|
|
58
|
+
for interceptor in interceptors:
|
|
59
|
+
interceptor.register_server(server)
|
|
60
|
+
|
|
42
61
|
test_settings = IsolateSettings(cache_dir=tmp_path / "cache")
|
|
43
62
|
with BridgeManager() as bridge:
|
|
44
63
|
servicer = IsolateServicer(bridge, test_settings)
|
|
64
|
+
|
|
65
|
+
for interceptor in interceptors:
|
|
66
|
+
interceptor.register_servicer(servicer)
|
|
67
|
+
|
|
45
68
|
definitions.register_isolate(servicer, server)
|
|
46
69
|
health.register_health(HealthServicer(), server)
|
|
47
70
|
host, port = "localhost", server.add_insecure_port("[::]:0")
|
|
@@ -69,14 +92,14 @@ def make_server(tmp_path):
|
|
|
69
92
|
|
|
70
93
|
|
|
71
94
|
@pytest.fixture
|
|
72
|
-
def stub(tmp_path):
|
|
73
|
-
with make_server(tmp_path) as stubs:
|
|
95
|
+
def stub(tmp_path, interceptors):
|
|
96
|
+
with make_server(tmp_path, interceptors) as stubs:
|
|
74
97
|
yield stubs.isolate_stub
|
|
75
98
|
|
|
76
99
|
|
|
77
100
|
@pytest.fixture
|
|
78
|
-
def health_stub(tmp_path):
|
|
79
|
-
with make_server(tmp_path) as stubs:
|
|
101
|
+
def health_stub(tmp_path, interceptors):
|
|
102
|
+
with make_server(tmp_path, interceptors) as stubs:
|
|
80
103
|
yield stubs.health_stub
|
|
81
104
|
|
|
82
105
|
|
|
@@ -719,3 +742,79 @@ def test_server_submit_server(
|
|
|
719
742
|
stub.Cancel(definitions.CancelRequest(task_id=task_id))
|
|
720
743
|
|
|
721
744
|
assert not list(stub.List(definitions.ListRequest()).tasks)
|
|
745
|
+
|
|
746
|
+
|
|
747
|
+
@pytest.mark.parametrize(
|
|
748
|
+
"interceptors",
|
|
749
|
+
[
|
|
750
|
+
[SingleTaskInterceptor()],
|
|
751
|
+
],
|
|
752
|
+
)
|
|
753
|
+
def test_server_single_use_submit(
|
|
754
|
+
stub: definitions.IsolateStub,
|
|
755
|
+
monkeypatch: Any,
|
|
756
|
+
) -> None:
|
|
757
|
+
import time
|
|
758
|
+
|
|
759
|
+
inherit_from_local(monkeypatch)
|
|
760
|
+
|
|
761
|
+
request = definitions.SubmitRequest(function=prepare_request(myserver))
|
|
762
|
+
task_id = stub.Submit(request).task_id
|
|
763
|
+
|
|
764
|
+
tasks = [task.task_id for task in stub.List(definitions.ListRequest()).tasks]
|
|
765
|
+
assert task_id in tasks
|
|
766
|
+
|
|
767
|
+
# Now try to Submit again
|
|
768
|
+
with pytest.raises(grpc.RpcError) as exc_info:
|
|
769
|
+
stub.Submit(request)
|
|
770
|
+
assert exc_info.value.code() == grpc.StatusCode.RESOURCE_EXHAUSTED
|
|
771
|
+
|
|
772
|
+
# And try to Run a task
|
|
773
|
+
with pytest.raises(grpc.RpcError) as exc_info:
|
|
774
|
+
run_request(stub, prepare_request(myserver))
|
|
775
|
+
assert exc_info.value.code() == grpc.StatusCode.RESOURCE_EXHAUSTED
|
|
776
|
+
|
|
777
|
+
stub.Cancel(definitions.CancelRequest(task_id=task_id))
|
|
778
|
+
time.sleep(1)
|
|
779
|
+
|
|
780
|
+
with pytest.raises(grpc.RpcError) as exc_info:
|
|
781
|
+
stub.List(definitions.ListRequest())
|
|
782
|
+
|
|
783
|
+
# Server should be shutting down
|
|
784
|
+
assert exc_info.value.code() == grpc.StatusCode.UNAVAILABLE
|
|
785
|
+
|
|
786
|
+
|
|
787
|
+
@pytest.mark.parametrize(
|
|
788
|
+
"interceptors",
|
|
789
|
+
[
|
|
790
|
+
[SingleTaskInterceptor()],
|
|
791
|
+
],
|
|
792
|
+
)
|
|
793
|
+
def test_server_single_use_run(
|
|
794
|
+
stub: definitions.IsolateStub,
|
|
795
|
+
monkeypatch: Any,
|
|
796
|
+
) -> None:
|
|
797
|
+
import time
|
|
798
|
+
|
|
799
|
+
inherit_from_local(monkeypatch)
|
|
800
|
+
|
|
801
|
+
run_function(stub, check_machine)
|
|
802
|
+
time.sleep(1)
|
|
803
|
+
|
|
804
|
+
# Now try to Submit again
|
|
805
|
+
with pytest.raises(grpc.RpcError) as exc_info:
|
|
806
|
+
submit_request = definitions.SubmitRequest(function=prepare_request(myserver))
|
|
807
|
+
stub.Submit(submit_request)
|
|
808
|
+
|
|
809
|
+
assert exc_info.value.code() == grpc.StatusCode.UNAVAILABLE
|
|
810
|
+
|
|
811
|
+
# And try to Run a task
|
|
812
|
+
with pytest.raises(grpc.RpcError) as exc_info:
|
|
813
|
+
run_function(stub, check_machine)
|
|
814
|
+
|
|
815
|
+
assert exc_info.value.code() == grpc.StatusCode.UNAVAILABLE
|
|
816
|
+
|
|
817
|
+
with pytest.raises(grpc.RpcError) as exc_info:
|
|
818
|
+
stub.List(definitions.ListRequest())
|
|
819
|
+
|
|
820
|
+
assert exc_info.value.code() == grpc.StatusCode.UNAVAILABLE
|
|
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
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/agent_pb2_grpc.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{isolate-0.14.0 → isolate-0.14.2}/src/isolate/connections/grpc/definitions/common_pb2_grpc.py
RENAMED
|
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
|
|
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
|