Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions runpod/serverless/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@

log = RunPodLogger()


def handle_uncaught_exception(exc_type, exc_value, exc_traceback):
log.error(f"Uncaught exception | {exc_type}; {exc_value}; {exc_traceback};")

sys.excepthook = handle_uncaught_exception


# ---------------------------------------------------------------------------- #
# Run Time Arguments #
# ---------------------------------------------------------------------------- #
Expand Down
14 changes: 10 additions & 4 deletions runpod/serverless/modules/rp_scale.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,10 @@ async def run(self):
tasks = [jobtake_task, jobrun_task]

# Concurrently run both tasks and wait for both to finish.
await asyncio.gather(*tasks)
results = await asyncio.gather(*tasks, return_exceptions=True)
for result in results:
if isinstance(result, Exception):
log.error(f"Caught exception: {result}")

def is_alive(self):
"""
Expand Down Expand Up @@ -134,9 +137,9 @@ async def get_jobs(self, session: ClientSession):
continue

try:
# Keep the connection to the blocking call up to 30 seconds
# Keep the connection to the blocking call up to 90 seconds
acquired_jobs = await asyncio.wait_for(
get_job(session, jobs_needed), timeout=30
get_job(session, jobs_needed), timeout=90
)

if not acquired_jobs:
Expand Down Expand Up @@ -197,7 +200,10 @@ async def run_jobs(self, session: ClientSession):
await asyncio.sleep(0)

# Ensure all remaining tasks finish before stopping
await asyncio.gather(*tasks)
results = await asyncio.gather(*tasks, return_exceptions=True)
for result in results:
if isinstance(result, Exception):
log.error(f"Caught exception from run_jobs: {result}")

async def handle_job(self, session: ClientSession, job: dict):
"""
Expand Down
Loading