-
Notifications
You must be signed in to change notification settings - Fork 8
fix(core): memory leaks and resource management issues #114
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,9 @@ def Remove(self, peer: SourceRCONClient) -> None: | |
| self.logger.info(sys._getframe().f_code.co_name + f" Peer {peer.name} disconnected!") | ||
| self.peers.remove(peer) | ||
|
|
||
| def Close(self) -> None: | ||
| self._serv_sock.close() | ||
|
|
||
| async def _server(self) -> None: | ||
| while True: | ||
| peer_socket: socket.socket | ||
|
|
@@ -39,7 +42,7 @@ async def _server(self) -> None: | |
| self.password, | ||
| self.torchlight_handler.command_handler, | ||
| ) | ||
| asyncio.Task(self._peer_handler(peer)) | ||
| asyncio.ensure_future(self._peer_handler(peer)) | ||
| self.peers.append(peer) | ||
|
Comment on lines
+45
to
46
|
||
| self.logger.info(sys._getframe().f_code.co_name + f" Peer {peer.name} connected!") | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -20,7 +20,7 @@ def __init__(self, loop: asyncio.AbstractEventLoop | None, config: Config): | |
|
|
||
| self.Init() | ||
|
|
||
| asyncio.ensure_future(self._Connect(), loop=self.loop) | ||
| asyncio.ensure_future(self._Connect()) | ||
|
||
|
|
||
| async def _Connect(self) -> None: | ||
| # Connect to API | ||
|
|
@@ -137,7 +137,7 @@ def OnDisconnect(self, exc: Exception | None) -> None: | |
|
|
||
| self.Init() | ||
|
|
||
| asyncio.ensure_future(self._Connect(), loop=self.loop) | ||
| asyncio.ensure_future(self._Connect()) | ||
|
||
|
|
||
| def __del__(self) -> None: | ||
| self.logger.debug("~TorchlightHandler()") | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -51,7 +51,7 @@ def cli(config_folder: str) -> None: | |
| config["TorchRCON"], | ||
| torchlight_handler, | ||
| ) | ||
| asyncio.Task(rcon_server._server()) | ||
| asyncio.ensure_future(rcon_server._server()) | ||
|
||
|
|
||
| # Run! | ||
| event_loop.run_forever() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Close()is added but not called anywhere, so the listening socket will still remain open unless callers explicitly invoke it. Also,_server()runs an infinite accept loop; closing_serv_sockfrom another context will typically causesock_acceptto raise and the task to terminate with an exception unless it’s caught/handled. Consider wiringClose()into shutdown logic and updating_server()to exit cleanly onCancelledError/OSErrorwhen the socket is closed.