mirror of
https://github.com/All-Hands-AI/OpenHands.git
synced 2026-01-10 07:18:10 -05:00
Fix for issue where temp file is empty (#6669)
This commit is contained in:
@@ -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')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user