theres nothing wrong with what is illustrated, save for that most  
workstations can't run anywhere near 100 concurrent threads/INSERTS/pg  
connections at the same time.

it goes without saying that showing fragments of code is not very  
useful since your results cannot be verified.


On Aug 2, 2009, at 10:21 PM, drakkan wrote:

>
> The problem is riproducible with this simple script:
>
> import samodels as sa
> import threading
>
> def insertalarm():
>        s=sa.Session
>        a=sa.Allarmi(s.query(sa.TipoAllarmi).get(1))
>        s.add(a)
>        s.commit()
>
> for i in range(100):
>    t=threading.Thread(target=insertalarm)
>    t.start()
>
>
> with range(1) works as expect, if you change the range the script hang
> or give errors, I'm using scoped_session as you suggested
>
> On 3 Ago, 03:34, drakkan <drakkan1...@gmail.com> wrote:
>> After the select there is an insert, can three concurrent threads
>> inserting data in the same table cause the hang?
>>
>> If so how can I avoid this?
>>
>> Please note that until now the same application was using django orm
>> with no deadlock problems, I only changed the query to use sqlalchemy
>>
>> thanks
>> drakkan
>>
>> On 3 Ago, 03:20, Michael Bayer <mike...@zzzcomputing.com> wrote:
>>
>>> On Aug 2, 2009, at 9:02 PM, drakkan wrote:
>>
>>>> here is a sample sa output when the application hangs:
>>
>>>> 009-08-03 01:05:20,458 INFO sqlalchemy.engine.base.Engine.0x...1634
>>>> {'param_1': None}
>>>> 2009-08-03 01:05:33,673 INFO sqlalchemy.engine.base.Engine.0x... 
>>>> 1634
>>>> SELECT tipallarmi.id AS tipallarmi_id, tipallarmi.codice AS
>>>> tipallarmi_codice, tipallarmi.tipo AS tipallarmi_tipo
>>>> FROM tipallarmi
>>>> WHERE tipallarmi.codice = %(codice_1)s
>>>> LIMIT 1 OFFSET 0
>>>> 2009-08-03 01:05:33,681 INFO sqlalchemy.engine.base.Engine.0x... 
>>>> 1634
>>>> {'codice_1': 1}
>>>> 2009-08-03 01:05:33,679 INFO sqlalchemy.engine.base.Engine.0x... 
>>>> 1634
>>>> SELECT tipallarmi.id AS tipallarmi_id, tipallarmi.codice AS
>>>> tipallarmi_codice, tipallarmi.tipo AS tipallarmi_tipo
>>>> FROM tipallarmi
>>>> WHERE tipallarmi.codice = %(codice_1)s
>>>> LIMIT 1 OFFSET 0
>>>> 2009-08-03 01:05:33,681 INFO sqlalchemy.engine.base.Engine.0x... 
>>>> 1634
>>>> {'codice_1': 1}
>>>> 2009-08-03 01:05:33,680 INFO sqlalchemy.engine.base.Engine.0x... 
>>>> 1634
>>>> SELECT tipallarmi.id AS tipallarmi_id, tipallarmi.codice AS
>>>> tipallarmi_codice, tipallarmi.tipo AS tipallarmi_tipo
>>>> FROM tipallarmi
>>>> WHERE tipallarmi.codice = %(codice_1)s
>>>> LIMIT 1 OFFSET 0
>>>> 2009-08-03 01:05:33,682 INFO sqlalchemy.engine.base.Engine.0x... 
>>>> 1634
>>>> {'codice_1': 1}
>>
>>>> seems there are three concurrent threads making the same query
>>
>>> if you have three threads all calling query.get() then that would be
>>> the result.
>>
>>> none of the SELECTs should be causing deadlocks so something else is
>>> causing it to hang.
> >


--~--~---------~--~----~------------~-------~--~----~
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