Skip to content

feat: Added support for async watcher callbacks #340#341

Merged
leeqvip merged 3 commits intoapache:masterfrom
tanasecucliciu:feat/340-async-enforcer-async-update-for
Feb 9, 2024
Merged

feat: Added support for async watcher callbacks #340#341
leeqvip merged 3 commits intoapache:masterfrom
tanasecucliciu:feat/340-async-enforcer-async-update-for

Conversation

@tanasecucliciu
Copy link
Copy Markdown
Contributor

@tanasecucliciu tanasecucliciu commented Jan 29, 2024

AsyncEnforcer can now also await Watcher callbacks if they are Coroutines. Related to #340.

Fix: #340

AsyncEnforcer can now also await Watcher callbacks if they are Coroutines.
@casbin-bot
Copy link
Copy Markdown

@Nekotoxin please review

@casbin-bot casbin-bot requested a review from Nekotoxin January 29, 2024 18:53
@CLAassistant
Copy link
Copy Markdown

CLAassistant commented Jan 29, 2024

CLA assistant check
All committers have signed the CLA.

Copy link
Copy Markdown
Contributor

@leeqvip leeqvip left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add some unit tests to them?

@tanasecucliciu
Copy link
Copy Markdown
Contributor Author

Sure thing!

I've added pytests to verify the functionality of async watcher callbacks.

Note: I used the existing pytest for synchronous calls as a reference for creating this async version.
@hsluoyz
Copy link
Copy Markdown
Member

hsluoyz commented Feb 1, 2024

@tanasecucliciu fix linter

image

@tanasecucliciu tanasecucliciu force-pushed the feat/340-async-enforcer-async-update-for branch from 16c2489 to 6657f12 Compare February 1, 2024 20:15
Comment thread tests/test_watcher_ex.py

await e.save_policy()
self.assertEqual(w.notify_message, "called save policy")

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whether save_policy should also depend on auto_notify_watcher ?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hsluoyz I saw the same in go's casbin.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any updates on this issue?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@leeqvip it should behave the same way as Go

@leeqvip leeqvip merged commit c04d832 into apache:master Feb 9, 2024
github-actions bot pushed a commit that referenced this pull request Feb 9, 2024
# [1.36.0](v1.35.0...v1.36.0) (2024-02-09)

### Features

* Added support for async watcher callbacks [#340](#340) ([#341](#341)) ([c04d832](c04d832))
@github-actions
Copy link
Copy Markdown

github-actions bot commented Feb 9, 2024

🎉 This PR is included in version 1.36.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Chimou0 pushed a commit to Chimou0/pycasbin that referenced this pull request Jul 17, 2025
Chimou0 pushed a commit to Chimou0/pycasbin that referenced this pull request Jul 17, 2025
# [1.36.0](apache/casbin-pycasbin@v1.35.0...v1.36.0) (2024-02-09)

### Features

* Added support for async watcher callbacks [apache#340](apache#340) ([apache#341](apache#341)) ([c04d832](apache@c04d832))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

AsyncEnforcer doesn't support async calls for Watcher's update function

5 participants