Skip to content

Commit 4eb7bbe

Browse files
authored
fix: ensure max_parallel_requests is an int value in batch_check (#132)
2 parents 32d0aff + a118952 commit 4eb7bbe

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

openfga_sdk/client/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ async def _single_batch_check(
612612
semaphore.release()
613613

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

632632
max_parallel_requests = 10
633633
if options is not None and "max_parallel_requests" in options:
634-
max_parallel_requests = options["max_parallel_requests"]
634+
if (
635+
isinstance(options["max_parallel_requests"], str)
636+
and options["max_parallel_requests"].isdigit()
637+
):
638+
max_parallel_requests = int(options["max_parallel_requests"])
639+
elif isinstance(options["max_parallel_requests"], int):
640+
max_parallel_requests = options["max_parallel_requests"]
635641

636642
sem = asyncio.Semaphore(max_parallel_requests)
637643
batch_check_coros = [

openfga_sdk/sync/client/client.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ def _single_batch_check(
599599
)
600600

601601
def batch_check(
602-
self, body: list[ClientCheckRequest], options: dict[str, str] = None
602+
self, body: list[ClientCheckRequest], options: dict[str, str | int] = None
603603
):
604604
"""
605605
Run a set of checks
@@ -619,7 +619,13 @@ def batch_check(
619619

620620
max_parallel_requests = 10
621621
if options is not None and "max_parallel_requests" in options:
622-
max_parallel_requests = options["max_parallel_requests"]
622+
if (
623+
isinstance(options["max_parallel_requests"], str)
624+
and options["max_parallel_requests"].isdigit()
625+
):
626+
max_parallel_requests = int(options["max_parallel_requests"])
627+
elif isinstance(options["max_parallel_requests"], int):
628+
max_parallel_requests = options["max_parallel_requests"]
623629

624630
batch_check_response = []
625631

0 commit comments

Comments
 (0)