Spaces:
Running
Running
Download src/app.py from Agents-MCP-Hackathon/LLMGameHub: direct link, hf CLI and curl.
- Browser
- Download file 730 Bytes
-
https://huggingface.co/spaces/Agents-MCP-Hackathon/LLMGameHub/resolve/main/src/app.py
- Command line
-
hf download hf://spaces/Agents-MCP-Hackathon/LLMGameHub/src/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Agents-MCP-Hackathon/LLMGameHub/resolve/main/src/app.py
730 Bytes
| import subprocess | |
| import time | |
| import atexit | |
| import shutil | |
| from redis import Redis, ConnectionError | |
| REDIS_BIN = shutil.which("redis-server") | |
| if not REDIS_BIN: | |
| raise RuntimeError("redis-server not found. Ensure redis is installed via packages.txt") | |
| redis_cmd = [ | |
| REDIS_BIN, | |
| "--save", | |
| "", | |
| "--appendonly", | |
| "no", | |
| "--dir", | |
| "/tmp", | |
| "--pidfile", | |
| "/tmp/redis.pid", | |
| ] | |
| redis_process = subprocess.Popen(redis_cmd) | |
| redis_client = Redis() | |
| for _ in range(20): | |
| try: | |
| redis_client.ping() | |
| break | |
| except ConnectionError: | |
| time.sleep(0.5) | |
| else: | |
| raise RuntimeError("Failed to start redis-server") | |
| atexit.register(redis_process.terminate) | |
| time.sleep(0.5) | |
| import main | |