diff --git a/basedosdados_api/settings/base.py b/basedosdados_api/settings/base.py index 87245648..b4973cc4 100644 --- a/basedosdados_api/settings/base.py +++ b/basedosdados_api/settings/base.py @@ -409,10 +409,16 @@ HUEY = { "name": "api.queue", - "huey_class": "huey.SqliteHuey", + "huey_class": "huey.RedisHuey", "results": True, "immediate": False, - "filename": path.join(BASE_DIR, "queue.sqlite3"), + "connection": { + "host": getenv("REDIS_URL", "localhost"), + "port": getenv("REDIS_PORT", 6379), + "db": getenv("REDIS_DB", 1), + "read_timeout": 1, + "connection_pool": None, + }, "consumer": { "workers": 2, "worker_type": "thread", @@ -420,3 +426,4 @@ "periodic": True, }, } +HUEY = None diff --git a/poetry.lock b/poetry.lock index 37d4a438..09e7cdbf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -33,6 +33,18 @@ typing-extensions = {version = ">=4", markers = "python_version < \"3.11\""} [package.extras] tests = ["mypy (>=0.800)", "pytest", "pytest-asyncio"] +[[package]] +name = "async-timeout" +version = "4.0.3" +description = "Timeout context manager for asyncio programs" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "async-timeout-4.0.3.tar.gz", hash = "sha256:4640d96be84d82d02ed59ea2b7105a0f7b33abe8703703cd0ab0bf87c427522f"}, + {file = "async_timeout-4.0.3-py3-none-any.whl", hash = "sha256:7405140ff1230c310e51dc27b3145b9092d659ce68ff733fb0cefe3ee42be028"}, +] + [[package]] name = "autoflake" version = "2.2.1" @@ -1712,6 +1724,25 @@ files = [ {file = "PyYAML-6.0.1.tar.gz", hash = "sha256:bfdf460b1736c775f2ba9f6a92bca30bc2095067b8a9d77876d1fad6cc3b4a43"}, ] +[[package]] +name = "redis" +version = "5.0.1" +description = "Python client for Redis database and key-value store" +category = "main" +optional = false +python-versions = ">=3.7" +files = [ + {file = "redis-5.0.1-py3-none-any.whl", hash = "sha256:ed4802971884ae19d640775ba3b03aa2e7bd5e8fb8dfaed2decce4d0fc48391f"}, + {file = "redis-5.0.1.tar.gz", hash = "sha256:0dab495cd5753069d3bc650a0dde8a8f9edde16fc5691b689a566eda58100d0f"}, +] + +[package.dependencies] +async-timeout = {version = ">=4.0.2", markers = "python_full_version <= \"3.11.2\""} + +[package.extras] +hiredis = ["hiredis (>=1.0.0)"] +ocsp = ["cryptography (>=36.0.1)", "pyopenssl (==20.0.1)", "requests (>=2.26.0)"] + [[package]] name = "requests" version = "2.31.0" @@ -1958,4 +1989,4 @@ testing = ["big-O", "jaraco.functools", "jaraco.itertools", "more-itertools", "p [metadata] lock-version = "2.0" python-versions = "^3.10" -content-hash = "d4e9cf242d39d66db12c0d66126df3d352d539002a65b2da4f2504750666850b" +content-hash = "2585d7579592f3400f1b9379dc65b9b111596611c3b376e17e4b6d15dda33173" diff --git a/pyproject.toml b/pyproject.toml index fd485959..0d2524f0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -32,6 +32,7 @@ google-cloud-bigquery = "^3.11.3" faker = "^19.6.1" loguru = "^0.7.2" huey = "^2.5.0" +redis = "^5.0.1" [tool.poetry.group.dev.dependencies] black = "^22.3.0"