What's wrong with: import threading, PyLucene threading.Thread = PyLucene.PythonThread
Andreas Am Freitag, den 28.10.2005, 10:32 -0700 schrieb Andi Vajda: > > hmm > > i figured it out my self :D > > > > no more deferToThread ! > > > > use directly the PythonThread bubu :D > > > > def render_GET(self, request): > > #d = threads.deferToThread(self.processRequest, request) > > self.processRequest(request) > > return server.NOT_DONE_YET > > > > def processRequest(self, request): > > t=PythonThread(target=self.doSearch, args=(request,)) > > t.start() > > > > > > and in doSearch at the end of the thread i call: > > request.finish() to finish the Twisted Web output ! > > > > PyLucene rocks :D > > very nice ! > > > > keep up the good work. > > Yes, for using threads other than the main thread, you must use a > PyLucene.PythonThread. For the same reasons, a PyLucene.PythonThread can only > be created from the main thread or from another PyLucene.PythonThread. > This is because libgcj's garbage collector insists on needed to initialize > the > thread before it gets used. A thread cannot be used with libgcj 'after the > fact', it has to be created by libgcj. > > Does processRequest start a thread for every request ? > In Chandler, where we use Twisted and PyLucene together, we created a thread > pool whose threads are Python.PyLucene thread instances and it seems to work > well. > > Andi.. > > > > > > > Friday, October 28, 2005, 12:23:48 PM, Catalin Constantin wrote: > >> i am trying to run the search in a twisted web application. > > > >> in my twisted resource i have: > > > >> def render_GET(self, request): > >> d = threads.deferToThread(self.processRequest, request) > >> return server.NOT_DONE_YET > > > >> this seems not to be compatible with PyLucene. > > > >> i also tryed running a PythonThread but i get another error: > > > >> eg: > >> def processRequest(self, request): > >> print "inside process Request" > >> t=PythonThread(target=self.doSearch, args=(request,)) > >> print "Starting PyThread" > >> t.start() > >> t.join() > >> print "Done PyThread" > >> request.finish() > > > >> File "/usr/lib/python2.4/site-packages/PyLucene.py", line 3479, in start > >> assert (current.getName() == 'MainThread' or > >> isinstance(current, PythonThread)), "PythonThread can only be > >> started from main thread of from another PythonThread" > >> exceptions.AssertionError: PythonThread can only be started from > >> main thread of from another PythonThread > > > > > >> Any help would be very appreciated. > >> 10x. > > > > > > > > -- > > Catalin Constantin > > Bounce Software > > http://www.bounce-software.com > > http://www.cabanova.ro > > > > _______________________________________________ > > pylucene-dev mailing list > > [email protected] > > http://lists.osafoundation.org/mailman/listinfo/pylucene-dev > > > _______________________________________________ > pylucene-dev mailing list > [email protected] > http://lists.osafoundation.org/mailman/listinfo/pylucene-dev
signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil
_______________________________________________ pylucene-dev mailing list [email protected] http://lists.osafoundation.org/mailman/listinfo/pylucene-dev
