Skip to content

Commit

Permalink
Reset ctx_pid before logging on prediction cancel or failure
Browse files Browse the repository at this point in the history
  • Loading branch information
nevillelyh committed Dec 2, 2024
1 parent 6211adb commit cdf9985
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions python/coglet/file_runner.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,18 +170,19 @@ async def _predict(self, pid: str, req: Dict[str, Any]) -> None:
self._respond(pid, resp)
else:
resp['output'] = await self.runner.predict(req['input'])
self.ctx_pid.set(None)
resp['status'] = 'succeeded'
self.ctx_pid.set(None)
self.logger.info('prediction completed: id=%s', pid)
except asyncio.CancelledError:
resp['status'] = 'canceled'
self.ctx_pid.set(None)
self.logger.error('prediction canceled: id=%s', pid)
except Exception as e:
resp['error'] = str(e)
resp['status'] = 'failed'
self.ctx_pid.set(None)
self.logger.error('prediction failed: id=%s %s', pid, e)
finally:
self.ctx_pid.set(None)
resp['completed_at'] = util.now_iso()
self._respond(pid, resp)

Expand Down

0 comments on commit cdf9985

Please sign in to comment.