Skip to content

Commit c956a6c

Browse files
chore: add a log message when returning 503 due to low memory (#320)
Clarify what's causing the error for the user. To test, set the free minimum really high and check that the log message shows. ``` export UNSTRUCTURED_MEMORY_FREE_MINIMUM_MB=16000 make run-web-app file=sample-docs/layout-parser-paper.pdf curl -X POST 'http://localhost:8000/general/v0/general' --form files="@$file" ``` --------- Co-authored-by: Yuming Long <[email protected]>
1 parent f306062 commit c956a6c

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

prepline_general/api/general.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -503,6 +503,7 @@ def _check_free_memory():
503503
memory_free_minimum = int(os.environ.get("UNSTRUCTURED_MEMORY_FREE_MINIMUM_MB", 2048))
504504

505505
if mem.available <= memory_free_minimum * 1024 * 1024:
506+
logger.warning(f"Rejecting because free memory is below {memory_free_minimum} MB")
506507
raise HTTPException(
507508
status_code=503, detail="Server is under heavy load. Please try again later."
508509
)

0 commit comments

Comments
 (0)