From c4923a4352221416434c56365ae1d6de1071c50a Mon Sep 17 00:00:00 2001 From: ashwin1111 Date: Fri, 31 May 2024 20:51:32 +0530 Subject: [PATCH 1/2] Pgbouncer POC --- fyle_xero_api/settings.py | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/fyle_xero_api/settings.py b/fyle_xero_api/settings.py index 693f6d7b..baacbac1 100644 --- a/fyle_xero_api/settings.py +++ b/fyle_xero_api/settings.py @@ -213,16 +213,9 @@ # Database # https://docs.djangoproject.com/en/2.2/ref/settings/#databases -# Defaulting django engine for qcluster -if len(sys.argv) > 0 and sys.argv[1] == "qcluster": - DATABASES = {"default": dj_database_url.config()} -else: - DATABASES = { - "default": dj_database_url.config( - engine="django_db_geventpool.backends.postgresql_psycopg2" - ) - } +DATABASES = {"default": dj_database_url.config()} +DATABASES['default']['DISABLE_SERVER_SIDE_CURSORS'] = True DATABASES["cache_db"] = {"ENGINE": "django.db.backends.sqlite3", "NAME": "cache.db"} From f591d4887eea5ea40b640879df82c2d33d37cd62 Mon Sep 17 00:00:00 2001 From: ashwin1111 Date: Mon, 24 Jun 2024 16:59:18 +0530 Subject: [PATCH 2/2] Try async task instead of chain --- apps/xero/queue.py | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/apps/xero/queue.py b/apps/xero/queue.py index 0e249687..ac398927 100644 --- a/apps/xero/queue.py +++ b/apps/xero/queue.py @@ -3,7 +3,7 @@ from django.db.models import Q from django_q.models import Schedule -from django_q.tasks import Chain +from django_q.tasks import async_task from xerosdk.exceptions import InvalidGrant, UnsuccessfulAuthentication from apps.fyle.models import Expense, ExpenseGroup @@ -94,16 +94,14 @@ def __create_chain_and_run(fyle_credentials: FyleCredential, xero_connection, in :param fund_source: Fund source :return: None """ - chain = Chain() - chain.append("apps.fyle.tasks.sync_dimensions", fyle_credentials, True) + async_task("apps.fyle.tasks.sync_dimensions", fyle_credentials, True) - chain.append('apps.xero.tasks.update_expense_and_post_summary', in_progress_expenses, workspace_id, fund_source) + async_task('apps.xero.tasks.update_expense_and_post_summary', in_progress_expenses, workspace_id, fund_source) for task in chain_tasks: - chain.append(task['target'], task['expense_group_id'], task['task_log_id'], xero_connection, task['last_export']) + async_task(task['target'], task['expense_group_id'], task['task_log_id'], xero_connection, task['last_export']) - chain.append('apps.fyle.tasks.post_accounting_export_summary', fyle_credentials.workspace.fyle_org_id, workspace_id, fund_source, True) - chain.run() + async_task('apps.fyle.tasks.post_accounting_export_summary', fyle_credentials.workspace.fyle_org_id, workspace_id, fund_source, True) def schedule_bills_creation(workspace_id: int, expense_group_ids: List[str], is_auto_export: bool, fund_source: str) -> list: