[cse491] Homework #8 Problem
C. Titus Brown
ctb at msu.edu
Wed Oct 22 07:37:27 PDT 2008
Hi, Steven,
mea culpa -- I forgot to account for how sqlite deals with threads for
this HW. Thanks for pointing it out!
There are a couple of possible workarounds, and all of the simple ones
suck. But in the interests of sanity, I'll suggest the simplest -- turn
off threading in your server, i.e. in serve() just call
handle_connection directly without running it in a thread.
We'll explore better solutions next week.
thanks again,
--titus
On Wed, Oct 22, 2008 at 02:46:23AM -0400, Steven Cornfield wrote:
-> Hey CTB,
->
-> I seem to be having a problem with my login function now that I've adapted
-> it to work with the database.
-> When I run your tests, my code passes all of them. But when I try to login
-> through the browser, my server has the following exception:
->
-> *ProgrammingError: SQLite objects created in a thread can only be used in
-> that same thread.The object was created in thread id 1484 and this is thread
-> id 4580*
-> It makes perfect sense that your test would not cause this error to arise
-> since your test calls the function in isolation, and thus it isn't run in a
-> thread.
->
-> I created the conn variable globally at the top of my file, because that is
-> the only way that your CheckAddUser test would pass (it references my conn
-> by saying "conn = webserve.conn"). However, when I go to reference that
-> connection via my login function (and theoretically add_user as well, though
-> I don't currently have a way of testing that through the browser), it gave
-> me that error. What should I do to get around this? Creating a new sqlite3
-> object would seem to be the best way, but then it seems silly to have that
-> global one at the top that I can't use except for the purpose of passing the
-> unittests.
->
-> Any and all advice would be much appreciated.
->
-> --
-> Steven C
--
C. Titus Brown, ctb at msu.edu
More information about the cse491-fall-2008
mailing list