durusmail: quixote-users: Newbie question about threads
Newbie question about threads
2004-11-08
2004-11-08
2004-11-08
2004-11-08
2004-11-08
2004-11-09
2004-11-09
Byte-compyle Python/PTL files (was: Newbie question about threads)
2004-11-10
Newbie question about threads
Mike Orr
2004-11-08
I'm designing my first Quixote application, coming from a Webware
background.  It will have complex search queries in MySQL, and I'm
afraid this might become a performance bottleneck.  Management is
insisting on a combined text search that searches substrings in some
thirty text fields and a few one-to-many tables, and possibly doing
spelling correction too.  My understanding is that Quixote has neither
threads nor an asynchronous model, so all other requests will freeze
while a search query is running.

doc/multi-threaded.html in Quixote-1.2 shows how to modify the Publisher
so the "global" Request object is specific to the current thread.  But
shouldn't you have to do something more too?  Something has to create
the thread, connect the thread's output to Apache, and perhaps clean up
when the thread is done.  I imagine one could reimplement
Publisher.process_request() or Publisher.try_publish() to create a new
thread for the request.  But I assume if this was viable, somebody would
have done it already, hence my question.  (I'll actually be using
SessionPublisher or a custom subclass for authentication/permissions.)
Is this viable or am I barking up the wrong tree?

The alternative seems to be running Quixote under Twisted and using
Deferreds for the queries.  I'd rather avoid that route if possible.
Is anybody doing it that way successfully?

Does it matter which webserver adapter a threaded application uses?
I'm undecided between SCGI, FastCGI, and mod_python.  I'm currently
using CGI for development.

Also, I'm using a shelve for session management.  I assume that's not
thread safe.  I thought about making a pseudo-shelve using MySQL.  Is
there such a critter already somewhere?

I have another question about authentication/permissions in a separate
e-mail.

--
-Mike Orr (aka. Sluggo), mso@oz.net  (iron@sense-sea-MegaSub-1-465.oz.net)
   http://sluggo.kicks-ass.org/                  Cxu vi parolas Esperante?

reply