Skip to content

Commit

Permalink
fix: ensure max_parallel_requests is an int value in batch_check
Browse files Browse the repository at this point in the history
  • Loading branch information
evansims committed Sep 20, 2024
1 parent e2ce832 commit a118952
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
10 changes: 8 additions & 2 deletions openfga_sdk/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -612,7 +612,7 @@ async def _single_batch_check(
semaphore.release()

async def batch_check(
self, body: list[ClientCheckRequest], options: dict[str, str] = None
self, body: list[ClientCheckRequest], options: dict[str, str | int] = None
):
"""
Run a set of checks
Expand All @@ -631,7 +631,13 @@ async def batch_check(

max_parallel_requests = 10
if options is not None and "max_parallel_requests" in options:
max_parallel_requests = options["max_parallel_requests"]
if (
isinstance(options["max_parallel_requests"], str)
and options["max_parallel_requests"].isdigit()
):
max_parallel_requests = int(options["max_parallel_requests"])
elif isinstance(options["max_parallel_requests"], int):
max_parallel_requests = options["max_parallel_requests"]

sem = asyncio.Semaphore(max_parallel_requests)
batch_check_coros = [
Expand Down
10 changes: 8 additions & 2 deletions openfga_sdk/sync/client/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -599,7 +599,7 @@ def _single_batch_check(
)

def batch_check(
self, body: list[ClientCheckRequest], options: dict[str, str] = None
self, body: list[ClientCheckRequest], options: dict[str, str | int] = None
):
"""
Run a set of checks
Expand All @@ -619,7 +619,13 @@ def batch_check(

max_parallel_requests = 10
if options is not None and "max_parallel_requests" in options:
max_parallel_requests = options["max_parallel_requests"]
if (
isinstance(options["max_parallel_requests"], str)
and options["max_parallel_requests"].isdigit()
):
max_parallel_requests = int(options["max_parallel_requests"])
elif isinstance(options["max_parallel_requests"], int):
max_parallel_requests = options["max_parallel_requests"]

batch_check_response = []

Expand Down

0 comments on commit a118952

Please sign in to comment.