SIENTIAPDE-1082
Implement shutdown methods for Activities and Kafka; enhance error handling in worker main function
This commit is contained in:
@@ -2,6 +2,7 @@ from temporalio import workflow, client
|
||||
from temporalio.worker import Worker
|
||||
|
||||
with workflow.unsafe.imports_passed_through():
|
||||
import sys
|
||||
import os
|
||||
from sientia_do.notifications.handlers import NotificationHandler
|
||||
from sientia_do.temporal.utils.logger import get_logger
|
||||
@@ -91,7 +92,18 @@ async def main():
|
||||
|
||||
logger.info('Workers started successfully')
|
||||
|
||||
await asyncio.gather(*handlers)
|
||||
try:
|
||||
await asyncio.gather(*handlers)
|
||||
|
||||
except BaseException as e:
|
||||
logger.error("An unhandled exception occurred: %s", e, exc_info=True)
|
||||
finally:
|
||||
if notification_handler:
|
||||
notification_handler.shutdown()
|
||||
if activities:
|
||||
activities.shutdown()
|
||||
# Exit with a non-zero status code to indicate failure to Kubernetes
|
||||
sys.exit(1)
|
||||
|
||||
if __name__ == '__main__':
|
||||
asyncio.run(main())
|
||||
|
||||
Reference in New Issue
Block a user