-
-
Notifications
You must be signed in to change notification settings - Fork 68
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Using a Redis timeseries with TcpFakeServer results in the application hanging open due to multiple threads spawning/running in the background.
To Reproduce
Steps to reproduce the behavior:
- Follow the documentation here to start a server running in a thread.
- Connect to redis and create a redis TimeSeries client.
- run
timeseries.add() - application logic finishes, application is held open due to background threads
Expected behavior
It is expected that once the application finishes (i.e the timeseries.add() executes), the thread will also exit. It seems that multiple, non-daemon threads, are spawned during this action.
Desktop (please complete the following information):
- OS:Widnows 11
- Python 3.13.7
- redis-py version:2.31.0
dependencies = [
"kraken-client>=0.1.0",
"websockets>=12.0",
"colorlog>=6.7.0",
"opentelemetry-api>=1.35.0",
"opentelemetry-exporter-otlp>=1.35.0 ",
"opentelemetry-instrumentation-logging>=0.56b0",
"opentelemetry-sdk>=1.35.0",
"redis>=6.4.0",
"mock>=5.1.0",
"pandas>=2.1.3",
"pydantic>=2.5.2",
]
[tool.pdm.dev-dependencies]
dev = [
"setuptools>=68.2.2",
"pre-commit>=3.5.0",
"ruff>=0.1.11",
"fakeredis>=2.31.0"
]Additional context
Example to reproduce:
from threading import Thread
import time
from fakeredis import TcpFakeServer
from redis import Redis
from market_gather.datastream import Ticker
REDIS_IP = "127.0.0.1"
REDIS_PORT = 6379
REDIS_URL = f"redis://{REDIS_IP}:{REDIS_PORT}"
server_address = (REDIS_IP, REDIS_PORT)
server = TcpFakeServer(server_address, server_type="redis")
t = Thread(target=server.serve_forever, daemon=True)
t.start()
print("fake redis started")
redis: Redis = Redis.from_url(REDIS_URL)
print("creating timeseries")
timeseries = redis.ts()
timestamp = round(time.time() * 1000)
timeseries.add(
"ticker:test:thing",
timestamp,
0.5,
duplicate_policy="LAST",
labels={"symbol": "test", "type": "thing"},
)
print("complete")Output from above
python .\redis_test.py
fake redis started
creating timeseries
complete
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working