33 lines
1009 B
Python
33 lines
1009 B
Python
# -*- coding: utf-8 -*-
|
|
"""Read-only: decode ALL stale queue items with the library's own codec."""
|
|
import json
|
|
from collections import Counter
|
|
|
|
import redis
|
|
|
|
from bigqmt_signal_trader.redis_rpc import (
|
|
ORDER_METHODS, decode_rpc_request_payload)
|
|
|
|
with open(r"C:\redis\redis.conf") as f:
|
|
import re
|
|
pw = re.search(r"^requirepass (\S+)", f.read(), re.M).group(1)
|
|
rc = redis.Redis(host="127.0.0.1", port=6379, db=5, password=pw,
|
|
decode_responses=True)
|
|
Q = "bigqmt:rpc:queue:66639661"
|
|
|
|
items = rc.lrange(Q, 0, -1)
|
|
methods = Counter()
|
|
bad = 0
|
|
for it in items:
|
|
try:
|
|
obj = json.loads(decode_rpc_request_payload(it))
|
|
methods[obj.get("method", "?")] += 1
|
|
except Exception:
|
|
bad += 1
|
|
print("total:", len(items), "undecodable:", bad)
|
|
for m, c in methods.most_common():
|
|
tag = "ORDER!" if m in ORDER_METHODS else "read"
|
|
print(" %-30s %5d %s" % (m, c, tag))
|
|
print("ORDER total:", sum(c for m, c in methods.items() if m in ORDER_METHODS))
|
|
print("DONE6")
|