This is an automated email from the ASF dual-hosted git repository.

lahirujayathilake pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/airavata-portals.git


The following commit(s) were added to refs/heads/main by this push:
     new b1aa9b17f A method that pings with getAPIVersion() before using any 
pooled connection. If the ping fails the stale connection is discarded
b1aa9b17f is described below

commit b1aa9b17fad23bdfe4a377a41b4051cc0a5eb7b3
Author: lahiruj <[email protected]>
AuthorDate: Mon Mar 23 16:27:20 2026 -0400

    A method that pings with getAPIVersion() before using any pooled 
connection. If the ping fails the stale connection is discarded
---
 airavata-django-portal/django_airavata/utils.py | 19 ++++++++++++++++++-
 airavata-django-portal/django_airavata/wsgi.py  |  3 +++
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/airavata-django-portal/django_airavata/utils.py 
b/airavata-django-portal/django_airavata/utils.py
index c3559afa9..a9576c739 100644
--- a/airavata-django-portal/django_airavata/utils.py
+++ b/airavata-django-portal/django_airavata/utils.py
@@ -220,7 +220,24 @@ class SimpleThriftPool:
         return {'client': client, 'transport': transport}
 
     def get_connection(self):
-        return self._pool.get()
+        conn = self._pool.get()
+        if not self._is_alive(conn):
+            log.debug("Stale connection detected, creating new one")
+            try:
+                conn['transport'].close()
+            except Exception:
+                pass
+            conn = self._create_connection()
+        return conn
+
+    def _is_alive(self, conn):
+        try:
+            if not conn['transport'].isOpen():
+                return False
+            conn['client'].getAPIVersion()
+            return True
+        except Exception:
+            return False
 
     def return_connection(self, conn):
         try:
diff --git a/airavata-django-portal/django_airavata/wsgi.py 
b/airavata-django-portal/django_airavata/wsgi.py
index d20f3c708..97afe64ab 100644
--- a/airavata-django-portal/django_airavata/wsgi.py
+++ b/airavata-django-portal/django_airavata/wsgi.py
@@ -9,6 +9,9 @@ https://docs.djangoproject.com/en/1.10/howto/deployment/wsgi/
 
 import os
 
+os.environ.setdefault('GRPC_ENABLE_FORK_SUPPORT', '1')
+os.environ.setdefault('GRPC_POLL_STRATEGY', 'poll')
+
 from django.core.wsgi import get_wsgi_application
 
 os.environ.setdefault("DJANGO_SETTINGS_MODULE", "django_airavata.settings")

Reply via email to