Refactor: handle error when retrieving messages from monitor service
This commit refactors the code in the `migrate_messages_from_monitor_service_to_database` function to handle errors that may occur when retrieving messages from the monitor service. If an exception is raised, the error is logged and the function returns `False`. This ensures that the migration process can continue even if there is an issue with retrieving the messages.
This commit is contained in:
parent
089ad6695c
commit
67a34ffcb8
1 changed files with 6 additions and 2 deletions
|
|
@ -18,8 +18,12 @@ def migrate_messages_from_monitor_service_to_database(session: Session) -> bool:
|
||||||
from langflow.schema.message import Message
|
from langflow.schema.message import Message
|
||||||
from langflow.services.database.models.message import MessageTable
|
from langflow.services.database.models.message import MessageTable
|
||||||
|
|
||||||
monitor_service = get_monitor_service()
|
try:
|
||||||
messages_df = monitor_service.get_messages()
|
monitor_service = get_monitor_service()
|
||||||
|
messages_df = monitor_service.get_messages()
|
||||||
|
except Exception as e:
|
||||||
|
logger.error(f"Error retrieving messages from monitor service: {e}")
|
||||||
|
return False
|
||||||
|
|
||||||
if messages_df.empty:
|
if messages_df.empty:
|
||||||
logger.info("No messages to migrate.")
|
logger.info("No messages to migrate.")
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue