Skip to content
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

Ensure subprocess is terminated in serve_wheel #12482

Open
harupy opened this issue Jun 26, 2024 · 4 comments
Open

Ensure subprocess is terminated in serve_wheel #12482

harupy opened this issue Jun 26, 2024 · 4 comments
Assignees
Labels
good first issue Good for newcomers

Comments

@harupy
Copy link
Member

harupy commented Jun 26, 2024

Summary

To ensure the subprocess running the server is terminated, try-finally should be used.

diff --git a/conftest.py b/conftest.py
index 79987335d..6db5bde9a 100644
--- a/conftest.py
+++ b/conftest.py
@@ -364,10 +364,12 @@ def serve_wheel(request, tmp_path_factory):
         ],
         cwd=root,
     ) as prc:
-        url = f"http://localhost:{port}"
-        if existing_url := os.environ.get("PIP_EXTRA_INDEX_URL"):
-            url = f"{existing_url} {url}"
-        os.environ["PIP_EXTRA_INDEX_URL"] = url
-
-        yield
-        prc.terminate()
+        try:
+            url = f"http://localhost:{port}"
+            if existing_url := os.environ.get("PIP_EXTRA_INDEX_URL"):
+                url = f"{existing_url} {url}"
+            os.environ["PIP_EXTRA_INDEX_URL"] = url
+
+            yield
+        finally:
+            prc.terminate()

Notes

  • Make sure to open a PR from a non-master branch.

  • Sign off the commit using the -s flag when making a commit:

    git commit -s -m "..."
             # ^^ make sure to use this
  • Include #{issue_number} (e.g. #123) in the PR description when opening a PR.

@harupy harupy added the good first issue Good for newcomers label Jun 26, 2024
@dominik-pichler
Copy link

Hello @harupy, I am looking for my first contribution to MLFlow. Can I work on this issue ?

@harupy
Copy link
Member Author

harupy commented Jun 27, 2024

@dominik-pichler absolutely!

@dominik-pichler
Copy link

@harupy Great! can you assign it to me?

@harupy
Copy link
Member Author

harupy commented Jun 28, 2024

@dominik-pichler assigned!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants