public inbox for [email protected]  
help / color / mirror / Atom feed
PATCH: To fix the issue of highlighting error in the query tool (pgAdmin4)
2+ messages / 2 participants
[nested] [flat]

* PATCH: To fix the issue of highlighting error in the query tool (pgAdmin4)
@ 2016-09-09 12:36  Murtuza Zabuawala <[email protected]>
  0 siblings, 1 reply; 2+ messages in thread

From: Murtuza Zabuawala @ 2016-09-09 12:36 UTC (permalink / raw)
  To: pgadmin-hackers

Hi,

PFA patch for highlighting error in the query tool which was broken due to
commit: d6391c7e9b26e5e10bb3
RM#1676

*Issue: *
We removed timeout in poll function due to which we were not able fetch
error properly.


--
Regards,
Murtuza Zabuawala
EnterpriseDB: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers


Attachments:

  [application/octet-stream] RM_1676.patch (2.0K, 3-RM_1676.patch)
  download | inline diff:
diff --git a/web/pgadmin/utils/driver/psycopg2/__init__.py b/web/pgadmin/utils/driver/psycopg2/__init__.py
index d4465ea..95aa95c 100644
--- a/web/pgadmin/utils/driver/psycopg2/__init__.py
+++ b/web/pgadmin/utils/driver/psycopg2/__init__.py
@@ -1044,9 +1044,31 @@ Failed to reset the connection to the server due to following error:
         if state == psycopg2.extensions.POLL_OK:
             return self.ASYNC_OK
         elif state == psycopg2.extensions.POLL_WRITE:
-            return self.ASYNC_WRITE_TIMEOUT
+            # Wait for the given time and then check the return status
+            # If three empty lists are returned then the time-out is reached.
+            timeout_status = select.select([], [conn.fileno()], [], time)
+            if timeout_status == ([], [], []):
+                return self.ASYNC_WRITE_TIMEOUT
+
+            # poll again to check the state if it is still POLL_WRITE
+            # then return ASYNC_WRITE_TIMEOUT else return ASYNC_OK.
+            state = conn.poll()
+            if state == psycopg2.extensions.POLL_WRITE:
+                return self.ASYNC_WRITE_TIMEOUT
+            return self.ASYNC_OK
         elif state == psycopg2.extensions.POLL_READ:
-            return self.ASYNC_READ_TIMEOUT
+            # Wait for the given time and then check the return status
+            # If three empty lists are returned then the time-out is reached.
+            timeout_status = select.select([conn.fileno()], [], [], time)
+            if timeout_status == ([], [], []):
+                return self.ASYNC_READ_TIMEOUT
+
+            # poll again to check the state if it is still POLL_READ
+            # then return ASYNC_READ_TIMEOUT else return ASYNC_OK.
+            state = conn.poll()
+            if state == psycopg2.extensions.POLL_READ:
+                return self.ASYNC_READ_TIMEOUT
+            return self.ASYNC_OK
         else:
             raise psycopg2.OperationalError(
                 "poll() returned %s from _wait_timeout function" % state


^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: PATCH: To fix the issue of highlighting error in the query tool (pgAdmin4)
@ 2016-09-09 13:45  Dave Page <[email protected]>
  parent: Murtuza Zabuawala <[email protected]>
  0 siblings, 0 replies; 2+ messages in thread

From: Dave Page @ 2016-09-09 13:45 UTC (permalink / raw)
  To: Murtuza Zabuawala <[email protected]>; +Cc: pgadmin-hackers

Thanks, applied.

On Fri, Sep 9, 2016 at 1:36 PM, Murtuza Zabuawala
<[email protected]> wrote:
> Hi,
>
> PFA patch for highlighting error in the query tool which was broken due to
> commit: d6391c7e9b26e5e10bb3
> RM#1676
>
> Issue:
> We removed timeout in poll function due to which we were not able fetch
> error properly.
>
>
> --
> Regards,
> Murtuza Zabuawala
> EnterpriseDB: http://www.enterprisedb.com
> The Enterprise PostgreSQL Company
>
>
> --
> Sent via pgadmin-hackers mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgadmin-hackers
>



-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK: http://www.enterprisedb.com
The Enterprise PostgreSQL Company


-- 
Sent via pgadmin-hackers mailing list ([email protected])
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgadmin-hackers




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2016-09-09 13:45 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2016-09-09 12:36 PATCH: To fix the issue of highlighting error in the query tool (pgAdmin4) Murtuza Zabuawala <[email protected]>
2016-09-09 13:45 ` Dave Page <[email protected]>

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox