Skip to content

Commit

Permalink
RSDK-5175 - return file upload server error (#482)
Browse files Browse the repository at this point in the history
  • Loading branch information
stuqdog authored Nov 13, 2023
1 parent 6d726cf commit fd47f61
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/viam/app/app_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,8 @@ async def upload_module_file(self, module_file_info: Optional[ModuleFileInfo], f
await stream.send_message(request_module_file_info)
await stream.send_message(request_file, end=True)
response = await stream.recv_message()
assert response is not None
if not response:
await stream.recv_trailing_metadata() # causes us to throw appropriate gRPC error.
return response.url

async def get_module(self, module_id: str) -> Module:
Expand Down
3 changes: 2 additions & 1 deletion src/viam/app/data_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,8 @@ async def _file_upload(self, metadata: UploadMetadata, file_contents: FileData)
await stream.send_message(request_metadata)
await stream.send_message(request_file_contents, end=True)
response = await stream.recv_message()
assert response is not None
if not response:
await stream.recv_trailing_metadata() # causes us to throw appropriate gRPC error.
return response

@staticmethod
Expand Down
4 changes: 3 additions & 1 deletion src/viam/components/audio_input/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,9 @@ async def read() -> AsyncIterator[Audio]:
ChunksRequest(name=self.name, sample_format=SampleFormat.SAMPLE_FORMAT_FLOAT32_INTERLEAVED), end=True
)
response: Union[ChunksResponse, None] = await chunks_stream.recv_message()
assert response is not None and response.HasField("info")
if not response:
await chunks_stream.recv_trailing_metadata() # causes us to throw appropriate gRPC error.
assert response.HasField("info")
info = response.info

while True:
Expand Down

0 comments on commit fd47f61

Please sign in to comment.