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
from neo.exception import NeoException
from neo.client.handlers import storage, master
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.mq import MQ
from neo.client.pool import ConnectionPool
......@@ -124,7 +124,9 @@ class Application(object):
def __init__(self, master_nodes, name, connector=None, compress=True, **kw):
# Start polling thread
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
self._db = None
self.name = name
......@@ -1200,7 +1202,9 @@ class Application(object):
for conn in self.em.getConnectionList():
conn.close()
# Stop polling thread
neo.logging.info('Stopping %s', self.poll_thread)
self.poll_thread.stop()
psThreadedPoll()
close = __del__
def invalidationBarrier(self):
......
......@@ -15,7 +15,7 @@
# along with this program; if not, write to the Free Software
# 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
class ThreadedPoll(Thread):
......@@ -44,3 +44,16 @@ class ThreadedPoll(Thread):
def stop(self):
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