Hi Michael,

2011/11/7 Michael Bayer <[email protected]>

>
> On Nov 6, 2011, at 8:41 AM, Wei-Ning Huang wrote:
>
> >
> > db.query(Table).filter(...).update({'stamp': stamp})
> > db.commit()
> > results = db.query(Table).filter_by(stamp=stamp).all()  #
> ResourceClosedError raised here
> >
> > and the traceback print out the error at this point. If I'm
> understanding correctly, you said that the cursor is closed since the update
> > statement does not return any results. Since the cursor is closed so it
> rendered my next select statement invalid?
>
> no, not quite - the above indicates a SELECT is emitted, and then the
> cursor has no .description attribute.  This is a bug in either MySQL or
> mysql-python, or is some side effect of your application's environment or
> possibly high concurrency load.   When a SELECT is emitted,
> cursor.description should never be None, regardless of if there are
> actually rows or not.   I can't say exactly why you are seeing this.
>  Reproducing it as a MySQL-python test case would be key to reporting a bug
> for the Mysql-python project (also called MySQLdb).


Thanks, I'll see if I can reproduce it with a short snippet.

Can I ask you more about the queue operations you talked about?
currently I'm using like this:

results = db.query(Table).filter(condition & (Table.status !=
'QUEUED')).with_lockmode('update')
ids = [result.id for result in results]
db.query(Table).filter(Table.id.in_(ids)).delete()
return results

if this correct? I'm not sure if I can delete the rows selected with
lockmode 'update'.
Thanks for answering!

Regards,
Wei-Ning




>
> > So in theory
> > if I can reconnect (create a new session) to the database, I can get the
> next select results without the ResourceClosedError, am I
> > correct?
>
> reconnecting may resolve the symptom here but there's something weird
> going on for sure.
>
>
>
> --
> You received this message because you are subscribed to the Google Groups
> "sqlalchemy" group.
> To post to this group, send email to [email protected].
> 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.
>
>


-- 
AZ Huang <http://berelent.blogspot.com/>

-- 
You received this message because you are subscribed to the Google Groups 
"sqlalchemy" group.
To post to this group, send email to [email protected].
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