Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
beasteers committed Sep 17, 2023
1 parent a60579e commit 66c68b2
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 70 deletions.
12 changes: 0 additions & 12 deletions docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -41,15 +41,3 @@ services:
- redis
ports:
- '8035:8001'

redisstreamer-record:
build: .
container_name: redisstreamer-record
command: -m redis_streamer.agents.record
volumes:
- ./redis_streamer:/src/redis_streamer
environment:
REDIS_URL: redis://redis:6379
depends_on:
- redis
restart: unless-stopped
File renamed without changes.
60 changes: 2 additions & 58 deletions tests/monitor.py
Original file line number Diff line number Diff line change
@@ -1,63 +1,7 @@
import redis

class Monitor:
def __init__(self, connection_pool):
self.connection_pool = connection_pool
self.connection = None

def __del__(self):
try:
self.reset()
except:
pass

def reset(self):
if self.connection:
self.connection_pool.release(self.connection)
self.connection = None

def monitor(self):
if self.connection is None:
self.connection = self.connection_pool.get_connection(
'monitor', None)
self.connection.send_command("monitor")
return self.listen()

def parse_response(self):
msg = self.connection.read_response()
return

def listen(self):
while True:
yield self.parse_response()





class Monitor:
def __init__(self, r):
self.r = r

def run(self):
STATE = "waiting"
with r.monitor() as m:
for command in m.listen():
if STATE == "waiting":
pass
if STATE == "waiting":
pass

import redis

if __name__ == '__main__':
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
# monitor = Monitor(pool)
# commands = monitor.monitor()

# for c in commands:
# print(c)

r = redis.Redis(host='localhost', port=6379, db=0)
with r.monitor() as m:
for command in m.listen():
print({k: v[:50] if isinstance(v, (str, bytes)) else v for k, v in command.items()})
print({k: v[:50] if isinstance(v, (str, bytes)) else v for k, v in command.items()})

0 comments on commit 66c68b2

Please sign in to comment.