[pylucene-dev] SocketServer.ThreadingTCPServer
Andi Vajda
vajda at osafoundation.org
Wed Dec 15 10:35:27 PST 2004
Excellent !
Andi..
On Wed, 15 Dec 2004, Yura Smolsky wrote:
> Hello, Yura.
>
> It seems like I have found solution. Python's sources is real power. I
> have modified some classes and I got it!
>
> ------
> import time, socket, SocketServer, threading
> from PyLucene import *
>
> class PyLuceneThread(threading.Thread):
> def run(self):
> return attachCurrentThread(super(PyLuceneThread, self))
>
> class MyThreadingMixIn:
> """Mix-in class to handle each request in a new thread."""
>
> # Decides how threads will act upon termination of the
> # main process
> daemon_threads = False
>
> def process_request_thread(self, request, client_address):
> """Same as in BaseServer but as a thread.
>
> In addition, exception handling is done here.
>
> """
> try:
> self.finish_request(request, client_address)
> self.close_request(request)
> except:
> self.handle_error(request, client_address)
> self.close_request(request)
>
> def process_request(self, request, client_address):
> """Start a new thread to process the request."""
> # this code is a bit changed for PyLucene
> t = PyLuceneThread(target = self.process_request_thread,
> args = (request, client_address))
> if self.daemon_threads:
> t.setDaemon (1)
> t.start()
>
> class MyThreadingTCPServer(MyThreadingMixIn, SocketServer.TCPServer): pass
> -----
>
> so I can use MyThreadingTCPServer as ThreadingTCPServer but with
> PyLucene support.
>
> YS> How can I make it work with subj?
>
> YS> I know that I need to do following:
> YS> class PyLuceneThread(threading.Thread):
> YS> def run(self):
> YS> return
> YS> PyLucene.attachCurrentThread(super(PyLuceneThread, self))
>
> YS> But how can I do this with high-level ThreadingTCPServer?
>
> YS> Yura Smolsky,
>
>
> YS> _______________________________________________
> YS> pylucene-dev mailing list
> YS> pylucene-dev at osafoundation.org
> YS> http://lists.osafoundation.org/mailman/listinfo/pylucene-dev
>
>
>
>
> Yura Smolsky,
>
>
> _______________________________________________
> pylucene-dev mailing list
> pylucene-dev at osafoundation.org
> http://lists.osafoundation.org/mailman/listinfo/pylucene-dev
>
More information about the pylucene-dev
mailing list