Re: Problem with psycopg2 and asyncio

From: "Frank Millman" <frank(at)chagford(dot)com>
To: <psycopg(at)postgresql(dot)org>
Subject: Re: Problem with psycopg2 and asyncio
Date: 2016-03-02 07:48:30
Message-ID: 7F9386DEC8DD4C9B9ECF106A81A2E9CC@FrankLaptop
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: psycopg

On 01/03/16 17:24, Daniele Varrazzo wrote:

>
>> On Mon, Feb 29, 2016 at 2:52 PM, Frank Millman <frank(at)chagford(dot)com> wrote:
>>
>> > Of course I may just be doing something silly, in which case I would be
>> > delighted if someone pointed it out.
>>
>> Are you running psycopg in async mode or in green mode?
>>
> To be honest, I don’t know what that means, so I am probably running in
> green mode.

> I think you should have that under control if you want psycopg to
> perform ok in asynchronous environment.

> Call psycopg2.extensions.get_wait_callback(). If it returns None, then
> psycopg is simply blocking.

Either I am misunderstanding you, or you are misunderstanding me – I am not sure which.

I am not running psycopg ‘in an asynchronous environment’. It is running in its own thread, and is unaware that there is an event loop running in a different thread.

It boils down to the fact that psycopg running in one thread is blocking another thread from executing. Running pyodbc and sqlite3 in exactly the same conditions do not have this effect. Therefore my (quite possibly wrong) suspicion is that the GIL is not being released timeously, or at least psycopg is doing something different from the others.

If I have misunderstood, I would appreciate it if you would clarify how you see the problem. That should give me a clearer idea of the best way forward from here.

Thanks

Frank

In response to

Responses

Browse psycopg by date

  From Date Subject
Next Message Frank Millman 2016-03-02 08:19:13 Re: Problem with psycopg2 and asyncio
Previous Message Daniele Varrazzo 2016-03-01 15:30:14 Re: Problem with psycopg2 and asyncio