Skip to content

Commit fce3364

Browse files
IgorIgor
authored andcommitted
fix memory leak, if the method threw an exception, the loop was not closed
1 parent c1e1b31 commit fce3364

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

bitrix24/bitrix24.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -169,8 +169,10 @@ def callMethod(self, method: str, params: Dict[str, Any] = None, **kwargs) -> Di
169169
)
170170
loop = asyncio.new_event_loop()
171171
asyncio.set_event_loop(loop)
172-
result = loop.run_until_complete(self._call(method, params or kwargs))
173-
loop.close()
172+
try:
173+
result = loop.run_until_complete(self._call(method, params or kwargs))
174+
finally:
175+
loop.close()
174176
else:
175177
result = asyncio.ensure_future(self._call(method, params or kwargs))
176178
return result

0 commit comments

Comments
 (0)