Skip to content

Commit 647834e

Browse files
committed
add_function can support async and sync dynamically
1 parent 27bef13 commit 647834e

1 file changed

Lines changed: 3 additions & 0 deletions

File tree

casbin/core_enforcer.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
import copy
1616
import logging
1717
import re
18+
import asyncio
1819

1920
from casbin.effect import Effector, get_effector, effect_to_bool
2021
from casbin.model import Model, FunctionMap
@@ -457,6 +458,8 @@ def enforce_ex(self, *rvals):
457458
expression = self._get_expression(exp_with_rule, functions)
458459

459460
result = expression.eval(parameters)
461+
if asyncio.iscoroutine(result):
462+
result = asyncio.run(result)
460463

461464
if isinstance(result, bool):
462465
if not result:

0 commit comments

Comments
 (0)