Skip to content

Commit 27bef13

Browse files
committed
Revert "add_function can support both async and sync; add await enforce.enforce()"
This reverts commit 4ed70fd.
1 parent 4ed70fd commit 27bef13

2 files changed

Lines changed: 0 additions & 13 deletions

File tree

casbin/async_enforcer.py

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
# limitations under the License.
1414

1515
from functools import partial
16-
import asyncio
1716

1817
from casbin.async_management_enforcer import AsyncManagementEnforcer
1918
from casbin.util import join_slice, array_remove_duplicates, set_subtract
@@ -23,15 +22,6 @@ class AsyncEnforcer(AsyncManagementEnforcer):
2322
"""
2423
AsyncEnforcer = AsyncManagementEnforcer + RBAC_API + RBAC_WITH_DOMAIN_API
2524
"""
26-
async def enforce(self, *rvals):
27-
loop = asyncio.get_running_loop()
28-
result = await loop.run_in_executor(None, super().enforce, *rvals)
29-
return result
30-
31-
async def batch_enforce(self, rvals):
32-
"""batch_enforce enforce in batches"""
33-
tasks = [self.enforce(*request) for request in rvals]
34-
return await asyncio.gather(*tasks)
3525

3626
async def get_roles_for_user(self, name):
3727
"""gets the roles that a user has."""

casbin/core_enforcer.py

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

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

460459
result = expression.eval(parameters)
461-
if asyncio.iscoroutine(result):
462-
result = asyncio.run(result)
463460

464461
if isinstance(result, bool):
465462
if not result:

0 commit comments

Comments
 (0)