Hello,

I'm running into a hang case on issuing an INSERT to mysql.  Here's
some code.  Note that I don't really use sqlalchemy sessions or query
objects or anything, I've written my own...I'm only using sqlalchemy
for connection management.  So in some file foo.py, I have the
following:

All of this is in pylons:

engine = create_engine(dburi)

I have defined a transaction decorator:
def transaction(func):
    def do(*args, **kw):
        connection = engine.connect()
        transaction = connection.begin()
        try:
          # create some context here for the connection and pass it
through to later execute
          ret = func(ctx, *args, **kw)
          transaction.commit()
          connection.close()
          return ret
        except:
          # rollback for now
          transaction.rollback()
          connection.close()
    return do

Now all calls making sql queries will be decorated by @transaction:
@transaction
def bar(...)
    # do an INSERT here

The problem occurs when I nest these like this:

@transaction
def blah(...)
    Do a vanilla INSERT into mysql

@transaction
def blah2(...)
   Do some work here and then call blah like this:
   <work>
   id = blah(...)  <--- hang happens here

My assumption was that sqlalchemy would handle this as nested
transactions based on incrementing.  How does this affect the
connection pool etc..?  Any help in understanding this behavior would
be appreciated.

Thanks,

Sam


--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/sqlalchemy?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to