Hello all, I need to get this python script to run with eventlet. Currently it seems that eventlet monkey breaks the connection to rediss (Redis with TLS). How can I fix it? Which version of these libraries would make it work? Ping me if you need a test URL for Redis TLS
Need eventlet and monkey patch active to stay there
Need to work with Redis TLS (rediss)
Specify the requirements.txt
Has to work with Flask 2.3.X
Has to work with Python 3.9.X
import eventlet
eventlet.monkey_patch()
import datetime
import redis
import numpy as np
from urllib.parse import urlparse
from flask import Flask
my_application = Flask(__name__)
# Feel free to test with this
REDIS_URL = "rediss://:pbe6272829f62aa1f18c6ee4f8f55456aa71d044a75ca069a3b5f6b6963971b56@ec2-46-137-49-233.eu-west-1.compute.amazonaws.com:27779"
print("REDIS_URL: ", REDIS_URL)
host = urlparse(REDIS_URL).hostname
port = urlparse(REDIS_URL).port
password = urlparse(REDIS_URL).password
try:
my_application.redis = redis.Redis(
host=host,
port=port,
password=password,
ssl=True,
ssl_cert_reqs=None,
)
my_application.redis.set("redis", "ready")
except Exception as e:
print(f"Error: {e}")
@my_application.route("/")
def index():
# Set a value in Redis
my_application.redis.set("hello", str(datetime.datetime.now()))
return "Hello, World!"
if __name__ == "__main__":
my_application.run(debug=True)
My current libraries are
Flask==2.3.2
redis==5.0.1
gunicorn==20.1.0
setuptools==68.2.2
eventlet==0.35.1
math==3.9.0
json==2.0.9
datetime==4.3.0
SKILLS NEEDED
Backend
CONTACT
Reach outif you have any questions about this initialBounty