You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I want author to provide some directions about interface design if he agreed. so I or others can have confident in creating PR.
Rationale
AsyncManagementEnforcer.add_function accept only sync funciton. there will throw an error. when AsyncManagementEnforcer.enforce get called.
python stack embraces a lot of async this is an inconvenient to implentment sync match function only for using it with casbin
The Error
explain_index = -1
if not 0 == policy_len:
for i, pvals in enumerate(self.model["p"][ptype].policy):
if len(p_tokens) != len(pvals):
raise RuntimeError("invalid policy size")
p_parameters = dict(zip(p_tokens, pvals))
parameters = dict(r_parameters, **p_parameters)
if exp_has_eval:
rule_names = util.get_eval_value(exp_string)
rules = [util.escape_assertion(p_parameters[rule_name]) for rule_name in rule_names]
exp_with_rule = util.replace_eval(exp_string, rules)
expression = self._get_expression(exp_with_rule, functions)
result = expression.eval(parameters)
if isinstance(result, bool):
if not result:
policy_effects.add(Effector.INDETERMINATE)
continue
elif isinstance(result, float):
if 0 == result:
policy_effects.add(Effector.INDETERMINATE)
continue
else:
> raise RuntimeError("matcher result should be bool, int or float")
E RuntimeError: matcher result should be bool, int or float
.venv/lib/python3.11/site-packages/casbin/core_enforcer.py:469: RuntimeError
=================================================================================== short test summary info ====================================================================================
FAILED tests/test_casbin/test_plan_enforcement.py::test_plan_enforcement - RuntimeError: matcher result should be bool, int or float
Suggestion
add_function could support both sync and async dynamically
create await enforce.enforce() async function
might need a separate class or new function name ``
use async.gather() for perf await enforce.batch_enforce()
The text was updated successfully, but these errors were encountered:
Action
I want author to provide some directions about interface design if he agreed. so I or others can have confident in creating PR.
Rationale
AsyncManagementEnforcer.add_function
accept only sync funciton. there will throw an error. whenAsyncManagementEnforcer.enforce
get called.python stack embraces a lot of async this is an inconvenient to implentment sync match function only for using it with casbin
The Error
Suggestion
add_function
could support both sync and async dynamicallyawait enforce.enforce()
async functionasync.gather()
for perfawait enforce.batch_enforce()
The text was updated successfully, but these errors were encountered: