Skip to content

GIL Release in copy_from? #140

@psycoteam

Description

@psycoteam

Originally submitted by: Psycopg website

Submitted by: Walt Woods

Hey, we have an issue with our software where an entire Python interpreter locks up. Every thread is locked on PyEval_RestoreThread except one, which is in psycopg2:

Thread 24 (Thread 0x7fce8aeef700 (LWP 8655)):
#230  0x00007fce9a49eb23 in poll () from /lib/x86_64-linux-gnu/libc.so.6
#231  0x00007fce95fcb5ed in ?? () from /usr/lib/libpq.so.5
#232  0x00007fce95fcb670 in ?? () from /usr/lib/libpq.so.5
#233  0x00007fce95fc9841 in PQgetResult () from /usr/lib/libpq.so.5
#234  0x00007fce961f0f20 in _pq_copy_in_v3 (curs=0x7fcddc58ced8)
    at psycopg/pqpath.c:1322
#235  pq_fetch (curs=0x7fcddc58ced8) at psycopg/pqpath.c:1462
#236  0x00007fce961f12f1 in pq_execute (curs=0x7fcddc58ced8, query=
    0x7fcddc74c880 "COPY myQuery"..., async=0)
    at psycopg/pqpath.c:945
#237  0x00007fce961f5dbc in psyco_curs_copy_from (self=0x7fcddc58ced8, 
    args=<optimized out>, kwargs=<optimized out>) at psycopg/cursor_type.c:1336
#238  0x000000000049d585 in PyEval_EvalFrameEx ()

So... While the query stalling is happening on our side, it's still bothersome that the GIL isn't released during a COPY_FROM, especially since my understanding is that COPY_FROM is an IO intensive operation (waiting on network) that doesn't need to hold the GIL.

It'd be nice if the GIL wasn't locked for cursor copies.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions