Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not working with uvloop #3

Closed
chapagainmanoj opened this issue Jun 15, 2021 · 4 comments
Closed

not working with uvloop #3

chapagainmanoj opened this issue Jun 15, 2021 · 4 comments

Comments

@chapagainmanoj
Copy link

chapagainmanoj commented Jun 15, 2021

I tried your solution with threading but it throws me

asyncpg.exceptions._base.InterfaceError: cannot perform operation: another operation is in progress

nest_asyncio doesn't work either even if it works for asyncio loop but with some tradeoffs according to this discussion . So better solution could be rewriting some part of casbin itself to support async, and it seem pretty straight forward and it worked for me with these changes

@hsluoyz
Copy link

hsluoyz commented Jul 10, 2021

@sakti @isasetiawan

@basakest @techoner

@isasetiawan
Copy link
Member

Hi thank you for the contribution.

I think based on @chapagainmanoj changes every @to_sync() won't be necessary and we could plug in this adapter to asynccasbin, am i right?

@chapagainmanoj
Copy link
Author

chapagainmanoj commented Jul 12, 2021

Yes,
I have changed each io functions to async. I haven't tested all the features but only what I needed.
So you can do something like

pip install asynccasbin

adapter = DatabasesAdapter(db_conn)
...
e = casbin.Enforcer(casbin_conf_path, None) # adapter is set to None because it can't awaited in __init__
e.set_adapter(adapter)
if not e.is_filtered():
    await e.load_policy()

@hsluoyz
Copy link

hsluoyz commented Jan 24, 2023

@chapagainmanoj plz close this issue if resolved. Also welcome to add an asynccasbin pointer to pycasbin's README

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

No branches or pull requests

3 participants