On Thursday, March 8, 2012, Michael Bayer <mike...@zzzcomputing.com> wrote:
>
> On Mar 8, 2012, at 7:28 AM, Eric Lemoine wrote:
>
>> On Thu, Mar 8, 2012 at 3:59 PM, Eric Lemoine
>> <eric.lemo...@camptocamp.com> wrote:
>>> Hi
>>>
>>> My code basically does:
>>>
>>> ---
>>> engine = create_engine()
>>>
>>> table = Table('table', MetaData(), Column('id', Integer,
primary_key=True))
>>> table.create(bind=engine)
>>>
>>> Session = scoped_session(sessionmaker(bind=engine))
>>> Session.execute(text('SELECT id from table'))
>>> ---
>>>
>>> The last statement blocks forever. It's like table.create created a
>>> transaction, and locked the table. Session.execute is blocked on this
>>> lock.
>>>
>>> I use Postgres. Any idea what I'm doing wrong?
>>
>>
>> Here's the actual test case:
>>
>> ---
>> from sqlalchemy import Table, MetaData, Column, create_engine
>> from sqlalchemy import types, text
>>
>> engine = create_engine('postgresql://www-data:www-data@localhost
:5432/c2cgeoportal_test')
>>
>> table = Table('table_d', MetaData(),
>>              Column('id', types.Integer, primary_key=True)
>>              )
>> table.create(bind=engine)
>>
>> from sqlalchemy.orm import sessionmaker
>> Session = sessionmaker(bind=engine)
>> Session().execute(text('SELECT id FROM table_d')) # blocks forever!
>>
>> table.drop(bind=engine)
>
>
> if you do a "ps -ef | grep post" you can see it's making it to the drop.
 The drop is blocking because the execute of a SELECT has returned an open
cursor for you to consume.   The table has a reader within a transaction
distinct from that of the drop.

Obviously. Thank you Michael.

-- 
Eric Lemoine

Camptocamp France SAS
Savoie Technolac, BP 352
73377 Le Bourget du Lac, Cedex

Tel : 00 33 4 79 44 44 96
Mail : eric.lemo...@camptocamp.com
http://www.camptocamp.com

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to sqlalchemy@googlegroups.com.
To unsubscribe from this group, send email to 
sqlalchemy+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en.

Reply via email to