diff --git a/nodriver/core/_contradict.py b/nodriver/core/_contradict.py index e35434d..c770361 100644 --- a/nodriver/core/_contradict.py +++ b/nodriver/core/_contradict.py @@ -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() diff --git a/nodriver/core/connection.py b/nodriver/core/connection.py index dfc3fff..51606d0 100644 --- a/nodriver/core/connection.py +++ b/nodriver/core/connection.py @@ -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)