Fix concurrent use of conection.poll()

Close #1248
This commit is contained in:
Daniele Varrazzo 2021-06-03 00:06:31 +01:00
parent 359679b136
commit 22af61bc31
2 changed files with 7 additions and 0 deletions

1
NEWS
View File

@ -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`).

View File

@ -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");