Web2py does have the equivalent of SQLAlchemy sessions. When a request arrives web2py creates a new database connection object or pools an existing connection from a connection pool, then it creates a cursor object. All db IO in the request is done via the cursor object. This is thread-safe in the sense that the cursor is only used in one thread. As soon as the request completes, the transaction is committed or rolled back and the connection is closed or recycled.
You can pass the db object to a thread and use it in another thread BUT you must make sure that the other thread is joined before the request is returned and autocommit is done. Massimo On Dec 27, 2:50 pm, Thadeus Burgess <thade...@thadeusb.com> wrote: > Just curious in how it works in web2py. In SQLAlchemy sessions are > thread safe.. so uncommitted transactions are accessible from other > threads. > > -Thadeus > > On Sun, Dec 27, 2009 at 1:44 PM, mdipierro <mdipie...@cs.depaul.edu> wrote: > > You can commit db.commit() and db.rollback() explicitly. Just do it > > when you need. > > > The concept of cross-thread transaction is not well defined and would > > be very unsafe. Perhaps if you tell us what you are tring to achieve > > we can suggest a better way. > > > On Dec 27, 10:29 am, Thadeus Burgess <thade...@thadeusb.com> wrote: > >> Is it possible to disable auto_commit() so that it must be explicitly > >> called? > > >> And are the Transactions shared between threads? Or must they be > >> committed to be seen in other threads? > > >> -Thadeus > > >> On Sun, Dec 27, 2009 at 9:38 AM, Vasile Ermicioi <elff...@gmail.com> wrote: > >> > any changes in DAL about GAE transactions? > > >> > On Sun, Dec 27, 2009 at 5:35 PM, mdipierro <mdipie...@cs.depaul.edu> > >> > wrote: > > >> >> yes > > >> >> On Dec 27, 5:55 am, Thadeus Burgess <thade...@thadeusb.com> wrote: > >> >> > Does the DAL perform all queries on a transaction basis... that > >> >> > happens to commit() at the end of a successful request? and on an > >> >> > error the transaction is rolled back? > > >> >> > -Thadeus > > >> >> -- > > >> >> You received this message because you are subscribed to the Google > >> >> Groups > >> >> "web2py-users" group. > >> >> To post to this group, send email to web...@googlegroups.com. > >> >> To unsubscribe from this group, send email to > >> >> web2py+unsubscr...@googlegroups.com. > >> >> For more options, visit this group at > >> >>http://groups.google.com/group/web2py?hl=en. > > >> > -- > > >> > You received this message because you are subscribed to the Google Groups > >> > "web2py-users" group. > >> > To post to this group, send email to web...@googlegroups.com. > >> > To unsubscribe from this group, send email to > >> > web2py+unsubscr...@googlegroups.com. > >> > For more options, visit this group at > >> >http://groups.google.com/group/web2py?hl=en. > > > -- > > > You received this message because you are subscribed to the Google Groups > > "web2py-users" group. > > To post to this group, send email to web...@googlegroups.com. > > To unsubscribe from this group, send email to > > web2py+unsubscr...@googlegroups.com. > > For more options, visit this group > > athttp://groups.google.com/group/web2py?hl=en. > > -- You received this message because you are subscribed to the Google Groups "web2py-users" group. To post to this group, send email to web...@googlegroups.com. To unsubscribe from this group, send email to web2py+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/web2py?hl=en.