Ticket #862 (defect)
Opened 2 months ago
Last modified 2 months ago
ThreadMonitor needs explicit creation of 'start_thread' and 'stop_thread' listeners.
Status: new
| Reported by: | Andrew Stromnov <stromnov@gmail.com> | Assigned to: | fumanchu |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | CherryPy code | Keywords: | |
| Cc: |
Change History
10/01/08 00:49:49: Modified by fumanchu
10/01/08 04:21:45: Modified by Andrew Stromnov <stromnov@gmail.com>
For example, new version of pylucene (jcc based) needs explicit call of jvm.attachCurrentThread() (one per thread) before any calls to search engine.
class LuceneThreadManager(SimplePlugin):
def __init__(self, bus):
super(LuceneThreadManager, self).__init__(bus)
self.jvm = lucene.initVM(lucene.CLASSPATH, vmargs="-Xrs")
def start_thread(self, i):
self.jvm.attachCurrentThread()
...
ThreadManager(bus).subscribe()
LuceneThreadManager(bus).subscribe()
But start_thread() method will not be executed, because of absence of 'start_thread' in listeners sets. There are two ways:
1) explicit use of bus.subscribe(channel, callback, priority) method;
2) explicitly define
# ThreadManager() or LuceneThreadManager() def __init__(self, bus): ... self.bus.listeners.setdefault('start_thread', set()) self.bus.listeners.setdefault('stop_thread', set())
and use automatic listeners binding in SimplePlugin?.subscribe() method.


Can you elaborate? I don't understand what you're asking for.