Skip to content

Commit 66c68b2

Browse files
committed
simplify
1 parent a60579e commit 66c68b2

File tree

3 files changed

+2
-70
lines changed

3 files changed

+2
-70
lines changed

docker-compose.yaml

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,15 +41,3 @@ services:
4141
- redis
4242
ports:
4343
- '8035:8001'
44-
45-
redisstreamer-record:
46-
build: .
47-
container_name: redisstreamer-record
48-
command: -m redis_streamer.agents.record
49-
volumes:
50-
- ./redis_streamer:/src/redis_streamer
51-
environment:
52-
REDIS_URL: redis://redis:6379
53-
depends_on:
54-
- redis
55-
restart: unless-stopped
File renamed without changes.

tests/monitor.py

Lines changed: 2 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,63 +1,7 @@
1-
import redis
2-
3-
class Monitor:
4-
def __init__(self, connection_pool):
5-
self.connection_pool = connection_pool
6-
self.connection = None
7-
8-
def __del__(self):
9-
try:
10-
self.reset()
11-
except:
12-
pass
13-
14-
def reset(self):
15-
if self.connection:
16-
self.connection_pool.release(self.connection)
17-
self.connection = None
18-
19-
def monitor(self):
20-
if self.connection is None:
21-
self.connection = self.connection_pool.get_connection(
22-
'monitor', None)
23-
self.connection.send_command("monitor")
24-
return self.listen()
25-
26-
def parse_response(self):
27-
msg = self.connection.read_response()
28-
return
29-
30-
def listen(self):
31-
while True:
32-
yield self.parse_response()
33-
34-
35-
36-
37-
38-
class Monitor:
39-
def __init__(self, r):
40-
self.r = r
41-
42-
def run(self):
43-
STATE = "waiting"
44-
with r.monitor() as m:
45-
for command in m.listen():
46-
if STATE == "waiting":
47-
pass
48-
if STATE == "waiting":
49-
pass
50-
1+
import redis
512

523
if __name__ == '__main__':
53-
pool = redis.ConnectionPool(host='localhost', port=6379, db=0)
54-
# monitor = Monitor(pool)
55-
# commands = monitor.monitor()
56-
57-
# for c in commands:
58-
# print(c)
59-
604
r = redis.Redis(host='localhost', port=6379, db=0)
615
with r.monitor() as m:
626
for command in m.listen():
63-
print({k: v[:50] if isinstance(v, (str, bytes)) else v for k, v in command.items()})
7+
print({k: v[:50] if isinstance(v, (str, bytes)) else v for k, v in command.items()})

0 commit comments

Comments
 (0)