updated Services Task database

This commit is contained in:
2025-08-19 20:17:14 +03:00
parent e4f6afbc93
commit 4e6774a15b
25 changed files with 824 additions and 124 deletions

View File

@@ -9,6 +9,7 @@ class IsBankConfig:
NO_ATTACHMENT_FOLDER: str = "NoAttachment"
COMPLETED_FOLDER: str = "Completed"
SERVICE_NAME: str = "IsBankEmailService"
BANK_NAME: str = "IsBank"
TASK_DATA_PREFIX: str = ConfigServices.MAIN_TASK_PREFIX
TASK_MAILID_INDEX_PREFIX: str = ConfigServices.TASK_MAILID_INDEX_PREFIX
TASK_UUID_INDEX_PREFIX: str = ConfigServices.TASK_UUID_INDEX_PREFIX

View File

@@ -13,16 +13,28 @@ basicConfig(level=INFO, format=format, handlers=handlers)
logger = getLogger(IsBankConfig.SERVICE_NAME)
def initialize_service():
def drop(email_service: EmailReaderService):
"""Clean up resources"""
try:
email_service.commit()
except Exception as e:
print(f"Error during commit on drop: {str(e)}")
try:
email_service.logout()
except Exception as e:
print(f"Error during logout on drop: {str(e)}")
def initialize_service() -> EmailReaderService:
"""Initialize the service with proper error handling"""
try:
logger.info("Creating EmailReaderService")
email_service = EmailReaderService(IsBankConfig())
logger.info("Connecting to email service")
email_service.login_and_connect()
return email_service
except Exception as e:
drop(email_service)
logger.error(f"Service initialization failed: {str(e)}")
sleep(5)
return initialize_service()