mirror of
https://github.com/OpenHands/OpenHands.git
synced 2025-12-26 05:48:36 +08:00
Fix for issue where temp file is empty (#6669)
This commit is contained in:
parent
6c88b10c59
commit
2b40a92943
@ -142,11 +142,13 @@ class ActionExecutionClient(Runtime):
|
||||
stream=True,
|
||||
timeout=30,
|
||||
) as response:
|
||||
temp_file = tempfile.NamedTemporaryFile(delete=False)
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
if chunk: # filter out keep-alive new chunks
|
||||
temp_file.write(chunk)
|
||||
return Path(temp_file.name)
|
||||
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
||||
total_length = 0
|
||||
for chunk in response.iter_content(chunk_size=8192):
|
||||
if chunk: # filter out keep-alive new chunks
|
||||
total_length += len(chunk)
|
||||
temp_file.write(chunk)
|
||||
return Path(temp_file.name)
|
||||
except requests.Timeout:
|
||||
raise TimeoutError('Copy operation timed out')
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user