Hi,
I am using web2py as a frontend and i have a single script
("myscript.py") doing all the extra calculation based on the uploaded
files (unzipping zip file contents to tables, deleting other info
etc.) This script contains four threads and now the problem is that
these threads are accessing the same "DAL object->connection->cursor"
simultaneously which understandable produces "Commands out of sync"
errors.
In web2py, model is executed everytime a controller function is called
and new DAL db object is created. Now if i could take this behaviour
and add it in my "myscript.py" in a way that i could get a "new db
object" for every thread i have, this problem i described above would
disappear. This suggestion might not even be possible to do, so my
main question is what would be from the design perspective and/or
practically the best way to solve this issue?
One possible(?) way is to launch four scripts instead of one (separate
every thread to its own script). This way every script gets its own
"new db object". Problem is that i need these scripts
to communicate between them and easiest way would be to have them in a
single script.
Script is executed along web2py as guided in the manual: "python
web2py.py -S app -M -N -R applications/app/private/myscript.py"
Web2py: Version 1.95.1
DB: PostgreSQL 8.3 with psycopg 2.4.1 (threading level 2, ie. threads
can share a single db connection)
I'll gladly provide any additional information if needed!
Thanks in advance!