Skip to content

Commit

Permalink
Merge pull request #97 from ntamas/fix/independent-id-generators
Browse files Browse the repository at this point in the history
fix: fix undesired sharing of ID generators between protocol instances
  • Loading branch information
lnoor authored Dec 28, 2021
2 parents 0d35931 + bdf48c8 commit 285dddc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions tinyrpc/protocols/jsonrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -509,12 +509,12 @@ class JSONRPCProtocol(RPCBatchProtocol):

def __init__(
self,
id_generator: Generator[object, None, None] = default_id_generator(),
id_generator: Optional[Generator[object, None, None]] = None,
*args,
**kwargs
) -> None:
super(JSONRPCProtocol, self).__init__(*args, **kwargs)
self._id_generator = id_generator
self._id_generator = id_generator or default_id_generator()
self._pending_replies = []

def _get_unique_id(self) -> object:
Expand Down
4 changes: 2 additions & 2 deletions tinyrpc/protocols/msgpackrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -239,12 +239,12 @@ class MSGPACKRPCProtocol(RPCProtocol):

def __init__(
self,
id_generator: Generator[object, None, None] = default_id_generator(),
id_generator: Optional[Generator[object, None, None]] = None,
*args,
**kwargs
) -> None:
super(MSGPACKRPCProtocol, self).__init__(*args, **kwargs)
self._id_generator = id_generator
self._id_generator = id_generator or default_id_generator()

def _get_unique_id(self):
return next(self._id_generator)
Expand Down

0 comments on commit 285dddc

Please sign in to comment.