Commit cbb7371f authored by Vincent Pelletier's avatar Vincent Pelletier

Define a ps-ish method for ThreadedPoll threads.

Call it in client, right after starting and stopping poll thread.

git-svn-id: https://svn.erp5.org/repos/neo/trunk@2387 71dcc9de-d417-0410-9af5-da40c76e7ee4
parent 32e875b1
...@@ -39,7 +39,7 @@ from neo.client.exception import NEOStorageNotFoundError ...@@ -39,7 +39,7 @@ from neo.client.exception import NEOStorageNotFoundError
from neo.exception import NeoException from neo.exception import NeoException
from neo.client.handlers import storage, master from neo.client.handlers import storage, master
from neo.dispatcher import Dispatcher, ForgottenPacket from neo.dispatcher import Dispatcher, ForgottenPacket
from neo.client.poll import ThreadedPoll from neo.client.poll import ThreadedPoll, psThreadedPoll
from neo.client.iterator import Iterator from neo.client.iterator import Iterator
from neo.client.mq import MQ from neo.client.mq import MQ
from neo.client.pool import ConnectionPool from neo.client.pool import ConnectionPool
...@@ -124,7 +124,9 @@ class Application(object): ...@@ -124,7 +124,9 @@ class Application(object):
def __init__(self, master_nodes, name, connector=None, compress=True, **kw): def __init__(self, master_nodes, name, connector=None, compress=True, **kw):
# Start polling thread # Start polling thread
self.em = EventManager() self.em = EventManager()
self.poll_thread = ThreadedPoll(self.em) self.poll_thread = ThreadedPoll(self.em, name=name)
neo.logging.info('Started %s', self.poll_thread)
psThreadedPoll()
# Internal Attributes common to all thread # Internal Attributes common to all thread
self._db = None self._db = None
self.name = name self.name = name
...@@ -1200,7 +1202,9 @@ class Application(object): ...@@ -1200,7 +1202,9 @@ class Application(object):
for conn in self.em.getConnectionList(): for conn in self.em.getConnectionList():
conn.close() conn.close()
# Stop polling thread # Stop polling thread
neo.logging.info('Stopping %s', self.poll_thread)
self.poll_thread.stop() self.poll_thread.stop()
psThreadedPoll()
close = __del__ close = __del__
def invalidationBarrier(self): def invalidationBarrier(self):
......
...@@ -15,7 +15,7 @@ ...@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
from threading import Thread, Event from threading import Thread, Event, enumerate as thread_enum
import neo import neo
class ThreadedPoll(Thread): class ThreadedPoll(Thread):
...@@ -44,3 +44,16 @@ class ThreadedPoll(Thread): ...@@ -44,3 +44,16 @@ class ThreadedPoll(Thread):
def stop(self): def stop(self):
self._stop.set() self._stop.set()
def psThreadedPoll(log=None):
"""
Logs alive ThreadedPoll threads.
"""
if log is None:
log = neo.logging.info
for thread in thread_enum():
if not isinstance(thread, ThreadedPoll):
continue
log('Thread %s at 0x%x, %s', thread.getName(), id(thread),
thread._stop.isSet() and 'stopping' or 'running')
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment