Hello, Andi.
no problems. I have created some Pool class to resolve multiple
PythonThread issue until you fix this bug. It could be a but ugly, but
it works without leaks.
Anyone who needs can use it :)
AV> This means something's broken in PyLucene. Probably something to do with
AV> releasing stuff from the thread after it completes.
AV> Thanks for reporting this.
AV> Andi..
Yura Smolsky,
http://altervisionmedia.com/
#!/usr/bin/python2.4
from PyLucene import *
from Queue import *
import time
class _WorkerPythonThread(PythonThread):
def __init__(self, funFinished, name=None):
PythonThread.__init__(self, name=name)
self.__target = False
self.__args = ()
self.__kwargs = {}
self.__funFinished = funFinished
def setTargetArgs(self, target, args=(), kwargs={}):
self.__target = target
self.__args = args
self.__kwargs = kwargs
def run(self):
try:
if self.__target:
self.__target(*self.__args, **self.__kwargs)
else:
raise RuntimeError("Target function is wrong")
finally:
self.__funFinished(self)
class PoolThreadPython:
def __init__(self, amount=10):
self.__queue = Queue()
for i in range(amount):
self.__queue.put(_WorkerPythonThread(self.finishedNotify,
"Worker-%s" % i))
def finishedNotify(self, thread):
self.__queue.put(thread)
def getThread(self, target, args=(), kwargs={}):
thread = self.__queue.get()
thread.setTargetArgs(target, args, kwargs)
return thread
def realTask(num):
pass
funny1 = False
pool = PoolThreadPython(20)
for i in xrange(1000000):
th = pool.getThread(target=realTask, args=(i,))
th.start()
_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev