summaryrefslogtreecommitdiff
path: root/python/pgq/status.py
diff options
context:
space:
mode:
authorMarko Kreen2009-02-13 12:16:59 +0000
committerMarko Kreen2009-02-13 13:20:31 +0000
commit411f237ebfdce9532bbf01f51d46cdb91f7fe283 (patch)
tree851a378f1234629cf2f15d903ecea4ae88df126f /python/pgq/status.py
parentc8198c637b777296ec49b845395487242d730394 (diff)
python/pgq update
- remove the obsolete setconsumer stuff - New CascadedConsumer / CascadedWorker classes, that are based on regular pgq.Consumer - move RemoteConsumer / SerialConsumer out of pgq/consumer.py pgq.Consumer: - rename conf params and instance variables: pgq_queue_name -> queue_name pgq_consumer_id -> consumer_name - disable automatic registration on the queue, now script needs to be called with switches --register / --unregister - drop code to read from multiple-queues at once pgq.ticker: - drop event seq tracking code, this is now done in db
Diffstat (limited to 'python/pgq/status.py')
-rw-r--r--python/pgq/status.py40
1 files changed, 22 insertions, 18 deletions
diff --git a/python/pgq/status.py b/python/pgq/status.py
index f17539de..d3f285c0 100644
--- a/python/pgq/status.py
+++ b/python/pgq/status.py
@@ -4,15 +4,18 @@
import sys, os, skytools
-def ival(data, as = None):
+__all__ = ['PGQStatus']
+
+def ival(data, _as = None):
"Format interval for output"
- if not as:
- as = data.split('.')[-1]
+ if not _as:
+ _as = data.split('.')[-1]
numfmt = 'FM9999999'
expr = "coalesce(to_char(extract(epoch from %s), '%s') || 's', 'NULL') as %s"
- return expr % (data, numfmt, as)
+ return expr % (data, numfmt, _as)
class PGQStatus(skytools.DBScript):
+ """Info gathering and display."""
def __init__(self, args, check = 0):
skytools.DBScript.__init__(self, 'pgqadm', args)
@@ -28,7 +31,7 @@ class PGQStatus(skytools.DBScript):
pgver = cx.fetchone()[0]
cx.execute("select pgq.version()")
qver = cx.fetchone()[0]
- print "Postgres version: %s PgQ version: %s" % (pgver, qver)
+ print("Postgres version: %s PgQ version: %s" % (pgver, qver))
q = """select f.queue_name, f.queue_ntables, %s, %s,
%s, %s, q.queue_ticker_max_count
@@ -50,36 +53,37 @@ class PGQStatus(skytools.DBScript):
cx.execute(q)
consumer_rows = cx.dictfetchall()
- print "\n%-45s %9s %13s %6s" % ('Event queue',
- 'Rotation', 'Ticker', 'TLag')
- print '-' * 78
+ print("\n%-45s %9s %13s %6s" % ('Event queue',
+ 'Rotation', 'Ticker', 'TLag'))
+ print('-' * 78)
for ev_row in event_rows:
tck = "%s/%s/%s" % (ev_row['queue_ticker_max_count'],
ev_row['queue_ticker_max_lag'],
ev_row['queue_ticker_idle_period'])
rot = "%s/%s" % (ev_row['queue_ntables'], ev_row['queue_rotation_period'])
- print "%-45s %9s %13s %6s" % (
+ print("%-45s %9s %13s %6s" % (
ev_row['queue_name'],
rot,
tck,
ev_row['ticker_lag'],
- )
- print '-' * 78
- print "\n%-56s %9s %9s" % (
- 'Consumer', 'Lag', 'LastSeen')
- print '-' * 78
+ ))
+ print('-' * 78)
+ print("\n%-56s %9s %9s" % (
+ 'Consumer', 'Lag', 'LastSeen'))
+ print('-' * 78)
for ev_row in event_rows:
cons = self.pick_consumers(ev_row, consumer_rows)
self.show_queue(ev_row, cons)
- print '-' * 78
+ print('-' * 78)
db.commit()
def show_consumer(self, cons):
- print " %-54s %9s %9s" % (
+ print(" %-54s %9s %9s" % (
cons['consumer_name'],
- cons['lag'], cons['last_seen'])
+ cons['lag'], cons['last_seen']))
+
def show_queue(self, ev_row, consumer_rows):
- print "%(queue_name)s:" % ev_row
+ print("%(queue_name)s:" % ev_row)
for cons in consumer_rows:
self.show_consumer(cons)