Skip to content

Conversation

@favipcj
Copy link
Contributor

@favipcj favipcj commented May 7, 2025

Fix: #2

This PR covers changes that are needed when using flask-authz, specifically:

  1. Add should_reload and update_callback methods that flask-authz needs https://github.com/pycasbin/flask-authz/blob/master/flask_authz/casbin_enforcer.py#L66-L67
  2. Retry when Redis times out or when Redis is down for some time
  3. Be able to recreate threads after some time(10sec) that were killed for any reason for example when the redis connection dies even after the configured retries. (This is important when running this watcher + flask-authz)
  4. Add some error handling to the subscribe method to show message errors related to redis and close the redis connection before the thread is killed
  5. Be able to receive a logger instance as an argument when creating the watcher

To make this library work with any Python library Redis version including redis 5, a different instance of the Redis class was created for the subscriber and publisher, as that is required for Redis 5 and still works for other old versions as well.

CI/Unit test Running https://github.com/favipcj/redis-watcher-official/actions/runs/14891376002/job/41824001358

@favipcj
Copy link
Contributor Author

favipcj commented May 7, 2025

FYI @hsluoyz

@hsluoyz hsluoyz changed the title Add changes to allow redis-watcher to work with flask authz + redis 5 feat: Add changes to allow redis-watcher to work with flask authz + redis 5 May 8, 2025
@hsluoyz hsluoyz merged commit 624ec90 into officialpycasbin:master May 8, 2025
7 checks passed
@hsluoyz
Copy link
Contributor

hsluoyz commented May 8, 2025

@favipcj plz fix CI error: https://github.com/officialpycasbin/redis-watcher/actions/runs/14909021191/job/41878450101

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Add necessary changes to allow redis-watcher to work with flask authz

2 participants