We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
bug: Flaky test `tests/meltano/api/test_workers.py::TestUIAvailableWorker::test_open_browser`
### Meltano Version

N/A

### Python Version

NA

### Bug scope

API

### Operating System

N/A

### Description

From https://github.com/meltano/meltano/issues/6827

- https://github.com/meltano/meltano/actions/runs/3175819389/jobs/5174350171
- https://github.com/meltano/meltano/actions/runs/3159179840/jobs/5142085679
- https://github.com/meltano/meltano/actions/runs/3056794521/jobs/4931297918
- https://github.com/meltano/meltano/actions/runs/3182662282/jobs/5188896027
- https://github.com/meltano/meltano/actions/runs/3183540252/jobs/5190883701
- https://github.com/meltano/meltano/actions/runs/3184585185/jobs/5193156601

Of the recorded instances, we observe:
- They are all using `ubuntu-latest`
- They are all using Python 3.7
- They are using a variety of database backends

The error occurs on the assert on the last line of the following code block. We see that `requests_get` is always called 3 times, but `sleep` is called 300-500 times.

```python
    @mock.patch("webbrowser.open")
    @mock.patch("requests.get")
    def test_open_browser(self, requests_get, webbrowser_open, subject):
        error = mock.Mock(status_code=400)
        ok = mock.Mock(status_code=200)
        requests_get.side_effect = [error, error, ok]
        with mock.patch("time.sleep") as sleep:
            sleep.return_value = None
            subject.run()
            webbrowser_open.assert_called_with("http://localhost:5000")
            assert requests_get.call_count == sleep.call_count
```

### Code

_No response_

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `src/meltano/api/workers/ui_available_worker.py`
Content:
```
1 from __future__ import annotations
2 
3 import logging
4 import threading
5 import time
6 import traceback
7 import webbrowser
8 
9 import click
10 import requests
11 
12 from meltano.core.project_settings_service import ProjectSettingsService
13 
14 logger = logging.getLogger(__name__)
15 
16 SUCCESS_STATUS_CODE = 200
17 
18 
19 class UIAvailableWorker(threading.Thread):
20     def __init__(self, project, open_browser=False):
21         super().__init__()
22         self.project = project
23         self.open_browser = open_browser
24         self.settings_service = ProjectSettingsService(self.project)
25         self._terminate = False
26 
27     def run(self):
28         url = f"http://localhost:{self.settings_service.get('ui.bind_port')}"
29         headers = {"Host": self.settings_service.get("ui.server_name")}
30 
31         while not self._terminate:
32             try:
33                 response = requests.get(url, headers=headers)
34                 if response.status_code == SUCCESS_STATUS_CODE:
35                     click.secho(f"Meltano UI is now available at {url}", fg="green")
36                     if self.open_browser:
37                         webbrowser.open(url)
38                     self._terminate = True
39             except Exception:
40                 logger.debug(
41                     f"Exception encountered while trying to run Meltano UI:\n{traceback.format_exc()}"
42                 )
43 
44             time.sleep(2)
45 
46     def stop(self):
47         self._terminate = True
48
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/src/meltano/api/workers/ui_available_worker.py b/src/meltano/api/workers/ui_available_worker.py
--- a/src/meltano/api/workers/ui_available_worker.py
+++ b/src/meltano/api/workers/ui_available_worker.py
@@ -1,10 +1,11 @@
+"""Meltano UI worker thread definition."""
+
 from __future__ import annotations
 
 import logging
 import threading
 import time
 import traceback
-import webbrowser
 
 import click
 import requests
@@ -17,14 +18,21 @@
 
 
 class UIAvailableWorker(threading.Thread):
-    def __init__(self, project, open_browser=False):
+    """A thread subclass for Meltano UI workers."""
+
+    def __init__(self, project):
+        """Initialize the `UIAvailableWorker` thread.
+
+        Args:
+            project: The Meltano project.
+        """
         super().__init__()
         self.project = project
-        self.open_browser = open_browser
         self.settings_service = ProjectSettingsService(self.project)
         self._terminate = False
 
-    def run(self):
+    def run(self) -> None:
+        """Run the thread, and report when the Meltano UI becomes available."""
         url = f"http://localhost:{self.settings_service.get('ui.bind_port')}"
         headers = {"Host": self.settings_service.get("ui.server_name")}
 
@@ -33,8 +41,6 @@
                 response = requests.get(url, headers=headers)
                 if response.status_code == SUCCESS_STATUS_CODE:
                     click.secho(f"Meltano UI is now available at {url}", fg="green")
-                    if self.open_browser:
-                        webbrowser.open(url)
                     self._terminate = True
             except Exception:
                 logger.debug(
@@ -44,4 +50,5 @@
             time.sleep(2)
 
     def stop(self):
+        """Stop the thread."""
         self._terminate = True

{"golden_diff": "diff --git a/src/meltano/api/workers/ui_available_worker.py b/src/meltano/api/workers/ui_available_worker.py\n--- a/src/meltano/api/workers/ui_available_worker.py\n+++ b/src/meltano/api/workers/ui_available_worker.py\n@@ -1,10 +1,11 @@\n+\"\"\"Meltano UI worker thread definition.\"\"\"\n+\n from __future__ import annotations\n \n import logging\n import threading\n import time\n import traceback\n-import webbrowser\n \n import click\n import requests\n@@ -17,14 +18,21 @@\n \n \n class UIAvailableWorker(threading.Thread):\n-    def __init__(self, project, open_browser=False):\n+    \"\"\"A thread subclass for Meltano UI workers.\"\"\"\n+\n+    def __init__(self, project):\n+        \"\"\"Initialize the `UIAvailableWorker` thread.\n+\n+        Args:\n+            project: The Meltano project.\n+        \"\"\"\n         super().__init__()\n         self.project = project\n-        self.open_browser = open_browser\n         self.settings_service = ProjectSettingsService(self.project)\n         self._terminate = False\n \n-    def run(self):\n+    def run(self) -> None:\n+        \"\"\"Run the thread, and report when the Meltano UI becomes available.\"\"\"\n         url = f\"http://localhost:{self.settings_service.get('ui.bind_port')}\"\n         headers = {\"Host\": self.settings_service.get(\"ui.server_name\")}\n \n@@ -33,8 +41,6 @@\n                 response = requests.get(url, headers=headers)\n                 if response.status_code == SUCCESS_STATUS_CODE:\n                     click.secho(f\"Meltano UI is now available at {url}\", fg=\"green\")\n-                    if self.open_browser:\n-                        webbrowser.open(url)\n                     self._terminate = True\n             except Exception:\n                 logger.debug(\n@@ -44,4 +50,5 @@\n             time.sleep(2)\n \n     def stop(self):\n+        \"\"\"Stop the thread.\"\"\"\n         self._terminate = True\n", "issue": "bug: Flaky test `tests/meltano/api/test_workers.py::TestUIAvailableWorker::test_open_browser`\n### Meltano Version\n\nN/A\n\n### Python Version\n\nNA\n\n### Bug scope\n\nAPI\n\n### Operating System\n\nN/A\n\n### Description\n\nFrom https://github.com/meltano/meltano/issues/6827\r\n\r\n- https://github.com/meltano/meltano/actions/runs/3175819389/jobs/5174350171\r\n- https://github.com/meltano/meltano/actions/runs/3159179840/jobs/5142085679\r\n- https://github.com/meltano/meltano/actions/runs/3056794521/jobs/4931297918\r\n- https://github.com/meltano/meltano/actions/runs/3182662282/jobs/5188896027\r\n- https://github.com/meltano/meltano/actions/runs/3183540252/jobs/5190883701\r\n- https://github.com/meltano/meltano/actions/runs/3184585185/jobs/5193156601\r\n\r\nOf the recorded instances, we observe:\r\n- They are all using `ubuntu-latest`\r\n- They are all using Python 3.7\r\n- They are using a variety of database backends\r\n\r\nThe error occurs on the assert on the last line of the following code block. We see that `requests_get` is always called 3 times, but `sleep` is called 300-500 times.\r\n\r\n```python\r\n    @mock.patch(\"webbrowser.open\")\r\n    @mock.patch(\"requests.get\")\r\n    def test_open_browser(self, requests_get, webbrowser_open, subject):\r\n        error = mock.Mock(status_code=400)\r\n        ok = mock.Mock(status_code=200)\r\n        requests_get.side_effect = [error, error, ok]\r\n        with mock.patch(\"time.sleep\") as sleep:\r\n            sleep.return_value = None\r\n            subject.run()\r\n            webbrowser_open.assert_called_with(\"http://localhost:5000\")\r\n            assert requests_get.call_count == sleep.call_count\r\n```\n\n### Code\n\n_No response_\n", "before_files": [{"content": "from __future__ import annotations\n\nimport logging\nimport threading\nimport time\nimport traceback\nimport webbrowser\n\nimport click\nimport requests\n\nfrom meltano.core.project_settings_service import ProjectSettingsService\n\nlogger = logging.getLogger(__name__)\n\nSUCCESS_STATUS_CODE = 200\n\n\nclass UIAvailableWorker(threading.Thread):\n    def __init__(self, project, open_browser=False):\n        super().__init__()\n        self.project = project\n        self.open_browser = open_browser\n        self.settings_service = ProjectSettingsService(self.project)\n        self._terminate = False\n\n    def run(self):\n        url = f\"http://localhost:{self.settings_service.get('ui.bind_port')}\"\n        headers = {\"Host\": self.settings_service.get(\"ui.server_name\")}\n\n        while not self._terminate:\n            try:\n                response = requests.get(url, headers=headers)\n                if response.status_code == SUCCESS_STATUS_CODE:\n                    click.secho(f\"Meltano UI is now available at {url}\", fg=\"green\")\n                    if self.open_browser:\n                        webbrowser.open(url)\n                    self._terminate = True\n            except Exception:\n                logger.debug(\n                    f\"Exception encountered while trying to run Meltano UI:\\n{traceback.format_exc()}\"\n                )\n\n            time.sleep(2)\n\n    def stop(self):\n        self._terminate = True\n", "path": "src/meltano/api/workers/ui_available_worker.py"}], "after_files": [{"content": "\"\"\"Meltano UI worker thread definition.\"\"\"\n\nfrom __future__ import annotations\n\nimport logging\nimport threading\nimport time\nimport traceback\n\nimport click\nimport requests\n\nfrom meltano.core.project_settings_service import ProjectSettingsService\n\nlogger = logging.getLogger(__name__)\n\nSUCCESS_STATUS_CODE = 200\n\n\nclass UIAvailableWorker(threading.Thread):\n    \"\"\"A thread subclass for Meltano UI workers.\"\"\"\n\n    def __init__(self, project):\n        \"\"\"Initialize the `UIAvailableWorker` thread.\n\n        Args:\n            project: The Meltano project.\n        \"\"\"\n        super().__init__()\n        self.project = project\n        self.settings_service = ProjectSettingsService(self.project)\n        self._terminate = False\n\n    def run(self) -> None:\n        \"\"\"Run the thread, and report when the Meltano UI becomes available.\"\"\"\n        url = f\"http://localhost:{self.settings_service.get('ui.bind_port')}\"\n        headers = {\"Host\": self.settings_service.get(\"ui.server_name\")}\n\n        while not self._terminate:\n            try:\n                response = requests.get(url, headers=headers)\n                if response.status_code == SUCCESS_STATUS_CODE:\n                    click.secho(f\"Meltano UI is now available at {url}\", fg=\"green\")\n                    self._terminate = True\n            except Exception:\n                logger.debug(\n                    f\"Exception encountered while trying to run Meltano UI:\\n{traceback.format_exc()}\"\n                )\n\n            time.sleep(2)\n\n    def stop(self):\n        \"\"\"Stop the thread.\"\"\"\n        self._terminate = True\n", "path": "src/meltano/api/workers/ui_available_worker.py"}]}