Skip to content

Commit

Permalink
Send terminated output when canceling a concurrent input.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielshaar committed Oct 22, 2024
1 parent f339f96 commit 42fa468
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions modal/_container_io_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -401,9 +401,24 @@ async def _heartbeat_handle_cancellations(self) -> bool:

if input_ids_to_cancel:
if self._max_concurrency > 1:
outputs = []
for input_id in input_ids_to_cancel:
if input_id in self.current_inputs:
self.current_inputs[input_id].cancel()
outputs.append(
api_pb2.FunctionPutOutputsItem(
input_id=input_id,
result=api_pb2.GenericResult(
status=api_pb2.GenericResult.GENERIC_STATUS_TERMINATED
),
)
)

await retry_transient_errors(
self._client.stub.FunctionPutOutputs,
api_pb2.FunctionPutOutputsRequest(outputs=outputs),
max_retries=None, # Retry indefinitely, trying every 1s.
)

elif self.current_input_id in input_ids_to_cancel:
# This goes to a registered signal handler for sync Modal functions, or to the
Expand Down

0 comments on commit 42fa468

Please sign in to comment.