I apologized I missed this thread. There is a problem with this design. The web2py db object users the driver connection object. That cannot be shared among threads without locking.
You can have a backrgound process with the two threads but each of them must make its own DAL connection and db.commit(); db.close(). It would be much easier if you were to implement multiple threads that do not access the db object but use a thread safe queue to send and recv messages to/from a main thread and only this main thread uses db. It would be faster and you would not have problems with database locking.

