Skip to content

Commit

Permalink
refactor: add a comment about pythd lock
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati committed Sep 13, 2024
1 parent 20e1188 commit 0453663
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions example_publisher/pythd.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ def _create_request(self, method: str, params: List[Any] | Any) -> JSONRPCReques
)

async def send_request(self, request: JSONRPCRequest) -> JSONRPCResponse:
# Using a lock will result in a synchronous execution of the send_request method
# and response retrieval which makes the code easier but is not good for performance.
# It is not recommended to use this behaviour where there are concurrent requests
# being made to the server.
async with self.lock:
await self.client.send(request.to_json())
response = await self.client.recv()
Expand Down

0 comments on commit 0453663

Please sign in to comment.