mirror of
				https://github.com/inventree/InvenTree.git
				synced 2025-10-30 20:55:42 +00:00 
			
		
		
		
	Catch errors if the DB is not up
This commit is contained in:
		| @@ -7,7 +7,9 @@ import requests | ||||
| import logging | ||||
|  | ||||
| from datetime import datetime, timedelta | ||||
|  | ||||
| from django.core.exceptions import AppRegistryNotReady | ||||
| from django.db.utils import OperationalError, ProgrammingError | ||||
|  | ||||
|  | ||||
| logger = logging.getLogger(__name__) | ||||
| @@ -25,6 +27,7 @@ def schedule_task(taskname, **kwargs): | ||||
|         logger.warning("Could not start background tasks - App registry not ready") | ||||
|         return | ||||
|  | ||||
|     try: | ||||
|         if Schedule.objects.filter(func=taskname).exists(): | ||||
|             logger.info(f"Scheduled task '{taskname}' already exists. (Skipping)") | ||||
|         else: | ||||
| @@ -34,6 +37,9 @@ def schedule_task(taskname, **kwargs): | ||||
|                 func=taskname, | ||||
|                 **kwargs | ||||
|             ) | ||||
|     except (OperationalError, ProgrammingError): | ||||
|         # Required if the DB is not ready yet | ||||
|         pass | ||||
|  | ||||
|  | ||||
| def heartbeat(): | ||||
|   | ||||
		Reference in New Issue
	
	Block a user