Skip to content

Commit

Permalink
0.31 fix memory leak - thanks zxsleebu
Browse files Browse the repository at this point in the history
  • Loading branch information
ultrafunkamsterdam committed Jul 6, 2024
1 parent 805bb0e commit 688c948
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion nodriver/core/_contradict.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _camel_to_snake(s):
:param str s: string to be converted
:return: (str) snake_case version of s
"""
s = s.replace("-", "").replace(".", "")
s = s.replace("-", "").replace(".", "").replace(" ", "_")

return __RE_CAMEL_TO_SNAKE__.sub(r"_\1", s).lower()

Expand Down
6 changes: 5 additions & 1 deletion nodriver/core/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -551,8 +551,12 @@ async def listener_loop(self):
# response to our command
if message["id"] in self.connection.mapper:
# get the corresponding Transaction
tx = self.connection.mapper[message["id"]]

# pop to prevent memory leaks
# thanks to zxsleebu
tx = self.connection.mapper.pop(message["id"])
logger.debug("got answer for %s", tx)

# complete the transaction, which is a Future object
# and thus will return to anyone awaiting it.
tx(**message)
Expand Down

0 comments on commit 688c948

Please sign in to comment.