Skip to content

Commit

Permalink
Fix concurrent use of conection.poll()
Browse files Browse the repository at this point in the history
Close #1248
  • Loading branch information
dvarrazzo committed Jun 2, 2021
1 parent 359679b commit 22af61b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
1 change: 1 addition & 0 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Current release
What's new in psycopg 2.8.7
^^^^^^^^^^^^^^^^^^^^^^^^^^^

- Fix concurrent use of `!conection.poll()` (:ticket:`1248`).
- Accept empty params as `~psycopg2.connect()` (:ticket:`#1250`).
- Fix attributes refcount in `Column` initialisation (:ticket:`#1252`).
- Allow re-initialisation of static variables in the C module (:ticket:`#1267`).
Expand Down
6 changes: 6 additions & 0 deletions psycopg/connection_int.c
Original file line number Diff line number Diff line change
Expand Up @@ -904,8 +904,14 @@ _conn_poll_advance_read(connectionObject *self)

Dprintf("conn_poll: poll reading");

Py_BEGIN_ALLOW_THREADS;
pthread_mutex_lock(&(self->lock));

busy = pq_get_result_async(self);

pthread_mutex_unlock(&(self->lock));
Py_END_ALLOW_THREADS;

switch (busy) {
case 0: /* result is ready */
Dprintf("conn_poll: async_status -> ASYNC_DONE");
Expand Down

0 comments on commit 22af61b

Please sign in to comment.