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 On 3 Ago, 00:49, drakkan <drakkan1...@gmail.com> wrote: > In my postgres log I have: > > ERROR: duplicate key value violates unique constraint "allarmi_pkey" > > when sqlalchemy give the error but nothing when the application hangs > > On 2 Ago, 23:45, Michael Bayer <mike...@zzzcomputing.com> wrote: > > > unless theres some detail missing here, you should be using > > scoped_session() so that there's one session per thread. > > > On Aug 2, 2009, at 5:04 PM, drakkan wrote: > > > > Hi all, > > > > I know sqlalchemy session is not thread safe but in my application I > > > need to use thread, > > > > I have my session defined as following: > > > > engine = create_engine(connectionstring, echo=settings.DEBUG, > > > echo_pool=settings.DEBUG, > > > pool_size=20, max_overflow=400) > > > > session = sessionmaker(bind=engine) > > > sess=session() > > > > and I use sess to make database logic, my database is postgres > > > > In my app I launch two threads that can work the same object, suppose > > > I have an object named "tr" i pass tr.id to the thread and in the > > > thread I make a new query to get the object by id, additionally one > > > thread make read operation and the other write operation, this seems > > > not enough the database get locked and the application hang, any > > > hints? > > > > thanks > > > drakkan1000 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---