-
Notifications
You must be signed in to change notification settings - Fork 22
Avoid FD (file descriptor) leak #560
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
Conversation
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
| proc = subprocess.Popen( | ||
| cmd_list, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, cwd=cwd, env=env, text=True | ||
| ) | ||
| try: | ||
| stdout, stderr = proc.communicate(timeout=timeout) | ||
| returncode = proc.returncode | ||
| except subprocess.TimeoutExpired: | ||
| proc.kill() | ||
| try: | ||
| stdout, stderr = proc.communicate(timeout=5) | ||
| except subprocess.TimeoutExpired: | ||
| proc.terminate() | ||
| stdout, stderr = "", "Process terminated due to timeout" | ||
| returncode = -1 | ||
| finally: | ||
| # Ensure all pipes are closed | ||
| if proc.stdin: | ||
| proc.stdin.close() | ||
| if proc.stdout: | ||
| proc.stdout.close() | ||
| if proc.stderr: | ||
| proc.stderr.close() | ||
|
|
||
| return subprocess.CompletedProcess(cmd_list, returncode, stdout, stderr) |
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.
subprocess.run does this under the hood, doesn't make sense to reimplement it here.
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.
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.
we (Saurabh and I) don't really feel like a makefile is all that useful for us currently
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.
Okay, as we are not having many contributors?
I added because of thinking about ongoing hackathon.
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.
that's fair, but I don't think the hackathon participants will contribute to codeflash itself.
I think we can revisit something similar once uv adds their task runner which will be functionally equivalent
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.
Okay makes sense. We can just close this PR as of now as I didnt see much improvements in FD leak while optimizing a large repo throwing FD leaks error with this.
Testing it with https://github.com/Saga4/core/pulls where kept getting error:
User description
PR Type
Bug fix
Description
Close SQLite connections after usage
Use context manager for devnull file
Ensure subprocess pipes are closed
Add Makefile with leak test command
File Walkthrough
replay_test.py
Add SQLite connection cleanupcodeflash/benchmarking/replay_test.py
beta.py
Manage devnull file contextcodeflash/lsp/beta.py
codeflash_capture.py
Close capture database connectioncodeflash/verification/codeflash_capture.py
test_runner.py
Ensure subprocess pipes closedcodeflash/verification/test_runner.py
Makefile
Add development MakefileMakefile