In order to use PyLucene APIs from a thread other than the main thread that thread needs to be initialized by libgcj. Whether that is done via a thread subclass such as PyLucene.PythonThread or the old way, via the now defunct attachCurrentThread() function, there is no way around this as the Java garbage collector needs to know about the thread and its stack.


Hans Boehm, the person behind the libgcj garbage collector has said before that, ideally, new threads should be automatically detected by the garbage collector but that's not the way things work at the moment. Feel free to contact him on the GC specific mailing list [EMAIL PROTECTED] or on the GCJ mailing list [EMAIL PROTECTED] to discuss this further.

Andi..

On Fri, 11 Feb 2005, Yura Smolsky wrote:

Hello, Andi.

I have answer from creator of omniORBpy. He told that threads are
created in the C++ source. Is there a way to use PyLucene object
without inheriting from PyLucene.PythonThread class?

---------- Forward Message ----------
From:   Duncan Grisby <[EMAIL PROTECTED]>
To:     Yura Smolsky <[EMAIL PROTECTED]>
CC:     [EMAIL PROTECTED]
Time:   Fri, 11 Feb 2005 05:55:03 -0600
Subj:   [omniORB] Threads management for omniORBpy
Attach: <none>

On Thursday 10 February, Yura Smolsky wrote:
Does omniORBpy use worker threads defined in C++ sources or defined in
Python sources?..

C++. At the time threads are allocated to serve calls, omniORB doesn't know if the call is destined for a C++ or a Python servant.

Cheers,
Duncan.
---------- End of Forward ----------


It is not me! :) It is sources of omniORBpy. They use complicated logic
about management of threads. I suspect one very bad thing: they can
start new threads from C++ sources (some part of this software has
been written on C++).

AV> Yes, that could be a problem indeed.

AV> Andi..


AV> I don't understand why this class is so complicated and what you're doing with AV> those _thr_ variables. All you need to do from PyLucene's standpoint is extend AV> PyLucene.PythonThread, ensure its __init__ is called, instantiate the thread, AV> and then start it with its start() method.

AV> Andi..

AV> On Thu, 10 Feb 2005, Yura Smolsky wrote:

Hello, Andi.

yes, it has.
i am not confident about  _thr_act, _thr_acq, _thr_rel variables.
maybe they could affect.

_thr_init = PythonThread.__init__
_thr_id   = threading._get_ident
_thr_act  = threading._active
_thr_acq  = threading._active_limbo_lock.acquire
_thr_rel  = threading._active_limbo_lock.release

class WorkerThread(PythonThread):

   hooks = []

   def __init__(self):
       _thr_init(self, name="omniORB")
       self._Thread__started = 1
       self.id = _thr_id()
       _thr_acq()
       if _thr_act.has_key(self.id):
           self.add = 0
       else:
           self.add = 1
           _thr_act[self.id] = self
       _thr_rel()
       if self.add:
           for hook in self.hooks:
               hook(WTHREAD_CREATED, self)

   def delete(self):
       if self.add:
           for hook in self.hooks:
               hook(WTHREAD_DELETED, self)
           _thr_acq()
           del _thr_act[self.id]
           _thr_rel()

   def _set_daemon(self): return 1
   def join(self):        assert 0, "cannot join an omniORB WorkerThread"


AV> Does the WorkerThread class that extends PyLucene.PythonThread have an AV> __init__() method ? If so, does it call super(WorkerThread, AV> self).__init__(*args, **kwds) so that PyLucene.PythonThread's __init__ gets a AV> chance to run ?

AV> Andi..

AV> On Thu, 10 Feb 2005, Yura Smolsky wrote:

Hello, Andi.

I have checked through threading.currentThread() that code executed
under thread inherited from PythonThread. What could be wrong in this
case?

AV> Yes, 'collecting from unknown thread' means that libgcj is running a thread
AV> that was not initialized by it.

AV> Andi..

AV> On Sat, 1 Jan 2005, Yura Smolsky wrote:

Hello, pylucene-dev.

As I said early I try to run IndexSearcher under omniORBpy (CORBA)
server, which creates new thread for any call of server's method by
remote client.
I have replaced in the source of omniORBpy
WorkerThread(threading.Thread) to
WorkerThread(PyLucene.PythonThread).

But when I try to call some methods of server remotely then I got java
message from Server which contains IndexSearcher:

Collecting from unknown thread.

It seems like message is about garbage collection.
Does it mean that server start non PythonThread thread?.. What issue
does this message point to?


Yura Smolsky



_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev




AV>



Yura Smolsky,







AV>



Yura Smolsky,







AV>



Yura Smolsky,







AV>



Yura Smolsky,




_______________________________________________
pylucene-dev mailing list
[email protected]
http://lists.osafoundation.org/mailman/listinfo/pylucene-dev

Reply via email to