Skip to content

Commit

Permalink
test(server): increase timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
efiop committed Apr 3, 2024
1 parent 83582f3 commit 034a79b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
5 changes: 2 additions & 3 deletions src/isolate/server/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from functools import partial
from queue import Empty as QueueEmpty
from queue import Queue
from typing import Any, Callable, Dict, Iterator, List, Tuple, cast
from typing import Any, Callable, Iterator, cast
from urllib.request import Request, urlopen

import grpc
Expand Down Expand Up @@ -385,8 +385,7 @@ def Run(
context: ServicerContext,
) -> Iterator[definitions.PartialRunResult]:
try:
for message in self.run_function(request):
yield message
yield from self.run_function(request)
except GRPCException as exc:
return self.abort_with_msg(
f"{exc}",
Expand Down
16 changes: 11 additions & 5 deletions tests/test_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -683,15 +683,21 @@ def test_server_proper_error_delegation(
run_function(stub, send_unserializable_object, log_handler=user_logs)

assert exc_info.value.code() == grpc.StatusCode.INVALID_ARGUMENT
assert "Error while serializing the execution result (object of type <class 'frame'>)." in exc_info.value.details()
assert (
"Error while serializing the execution result (object of type <class 'frame'>)."
in exc_info.value.details()
)
assert not user_logs

user_logs = []
with pytest.raises(grpc.RpcError) as exc_info:
run_function(stub, raise_unserializable_object, log_handler=user_logs)

assert exc_info.value.code() == grpc.StatusCode.INVALID_ARGUMENT
assert "Error while serializing the execution result (object of type <class 'Exception'>)." in exc_info.value.details()
assert (
"Error while serializing the execution result (object of type <class 'Exception'>)."
in exc_info.value.details()
)
assert "relevant information" in "\n".join(log.message for log in user_logs)


Expand All @@ -706,12 +712,12 @@ def test_server_submit(
function=prepare_request(imitate_server),
callback=http_server.host,
)
response = stub.Submit(request)
stub.Submit(request)

partial_results: list[definitions.PartialRunResult] = []
partial_results: List[definitions.PartialRunResult] = []
while not any(pr.is_complete for pr in partial_results):
try:
message = http_server.messages.get(timeout=10)
message = http_server.messages.get(timeout=120)
except queue.Empty:
raise ValueError("No message received from the server within 5 seconds")

Expand Down

0 comments on commit 034a79b

Please sign in to comment.