[Neo-report] r2387 vincent - in /trunk/neo/client: app.py poll.py
nobody at svn.erp5.org
nobody at svn.erp5.org
Sat Oct 30 14:56:12 CEST 2010
Author: vincent
Date: Sat Oct 30 14:56:12 2010
New Revision: 2387
Log:
Define a ps-ish method for ThreadedPoll threads.
Call it in client, right after starting and stopping poll thread.
Modified:
trunk/neo/client/app.py
trunk/neo/client/poll.py
Modified: trunk/neo/client/app.py
==============================================================================
--- trunk/neo/client/app.py [iso-8859-1] (original)
+++ trunk/neo/client/app.py [iso-8859-1] Sat Oct 30 14:56:12 2010
@@ -39,7 +39,7 @@ from neo.client.exception import NEOStor
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):
Modified: trunk/neo/client/poll.py
==============================================================================
--- trunk/neo/client/poll.py [iso-8859-1] (original)
+++ trunk/neo/client/poll.py [iso-8859-1] Sat Oct 30 14:56:12 2010
@@ -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')
+
More information about the Neo-report
mailing list