Skip to content

Commit

Permalink
Merge pull request #988 from moonstream-to/add-internal-timeout
Browse files Browse the repository at this point in the history
Add internal timeout.
  • Loading branch information
Andrei-Dolgolev authored Dec 14, 2023
2 parents b7ea344 + 8bf0e72 commit 0348154
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
3 changes: 2 additions & 1 deletion moonstreamapi/moonstreamapi/routes/queries.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
MOONSTREAM_APPLICATION_ID,
MOONSTREAM_CRAWLERS_SERVER_PORT,
MOONSTREAM_CRAWLERS_SERVER_URL,
MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS,
MOONSTREAM_QUERIES_JOURNAL_ID,
MOONSTREAM_QUERY_TEMPLATE_CONTEXT_TYPE,
MOONSTREAM_S3_QUERIES_BUCKET,
Expand Down Expand Up @@ -473,7 +474,7 @@ async def update_query_data_handler(
if request_update.blockchain
else None,
},
timeout=5,
timeout=MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS,
)
except Exception as e:
logger.error(f"Error interaction with crawlers: {str(e)}")
Expand Down
14 changes: 14 additions & 0 deletions moonstreamapi/moonstreamapi/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,17 @@
"type": "function",
}
]

MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS_RAW = os.environ.get(
"MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS"
)
MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS = 10
try:
if MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS_RAW is not None:
MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS = int(
MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS_RAW
)
except:
raise Exception(
f"Could not parse MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS as int: {MOONSTREAM_INTERNAL_REQUEST_TIMEOUT_SECONDS_RAW}"
)

0 comments on commit 0348154

Please sign in to comment.