prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  tests: exp executor teardown is flaky on windows
  Looks like there is some race condition on windows that sometimes happens between cleaning up the test `tmp_dir` and cleaning up the experiments executor temp directory (which is placed in `tmp_dir/.dvc/tmp/...`). May be better to go back to running experiments in system `$TEMP` instead of `.dvc/tmp` (for win tests only)?
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `dvc/repo/experiments/executor/local.py`
  Content:
  ```
  1 import logging
  2 import os
  3 import sys
  4 from tempfile import TemporaryDirectory
  5 from typing import Optional
  6 
  7 from dvc.utils.fs import remove
  8 
  9 from .base import BaseExecutor
  10 
  11 logger = logging.getLogger(__name__)
  12 
  13 
  14 class BaseLocalExecutor(BaseExecutor):
  15     """Base local machine executor."""
  16 
  17     @property
  18     def git_url(self) -> str:
  19         root_dir = os.path.abspath(self.root_dir)
  20         if os.name == "nt":
  21             root_dir = root_dir.replace(os.sep, "/")
  22         return f"file://{root_dir}"
  23 
  24 
  25 class TempDirExecutor(BaseLocalExecutor):
  26     """Temp directory experiment executor."""
  27 
  28     # Temp dir executors should warn if untracked files exist (to help with
  29     # debugging user code), and suppress other DVC hints (like `git add`
  30     # suggestions) that are not applicable outside of workspace runs
  31     WARN_UNTRACKED = True
  32     QUIET = True
  33 
  34     def __init__(
  35         self,
  36         *args,
  37         tmp_dir: Optional[str] = None,
  38         cache_dir: Optional[str] = None,
  39         **kwargs,
  40     ):
  41         self._tmp_dir = TemporaryDirectory(dir=tmp_dir)
  42         kwargs["root_dir"] = self._tmp_dir.name
  43         super().__init__(*args, **kwargs)
  44         if cache_dir:
  45             self._config(cache_dir)
  46         logger.debug(
  47             "Init temp dir executor in dir '%s'", self._tmp_dir,
  48         )
  49 
  50     def _config(self, cache_dir):
  51         local_config = os.path.join(self.dvc_dir, "config.local")
  52         logger.debug("Writing experiments local config '%s'", local_config)
  53         with open(local_config, "w") as fobj:
  54             fobj.write(f"[cache]\n    dir = {cache_dir}")
  55 
  56     def cleanup(self):
  57         super().cleanup()
  58         logger.debug("Removing tmpdir '%s'", self._tmp_dir)
  59         try:
  60             self._tmp_dir.cleanup()
  61         except PermissionError:
  62             if os.name == "nt" and sys.version_info < (3, 8):
  63                 # see https://bugs.python.org/issue26660
  64                 remove(self._tmp_dir.name)
  65                 return
  66             raise
  67
  ```
  --- 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()
  
  ```
  
golden_diff: diff --git a/dvc/repo/experiments/executor/local.py b/dvc/repo/experiments/executor/local.py
  --- a/dvc/repo/experiments/executor/local.py
  +++ b/dvc/repo/experiments/executor/local.py
  @@ -1,6 +1,5 @@
   import logging
   import os
  -import sys
   from tempfile import TemporaryDirectory
   from typing import Optional
   
  @@ -56,11 +55,4 @@
       def cleanup(self):
           super().cleanup()
           logger.debug("Removing tmpdir '%s'", self._tmp_dir)
  -        try:
  -            self._tmp_dir.cleanup()
  -        except PermissionError:
  -            if os.name == "nt" and sys.version_info < (3, 8):
  -                # see https://bugs.python.org/issue26660
  -                remove(self._tmp_dir.name)
  -                return
  -            raise
  +        remove(self._tmp_dir.name)
  
verification_info: {"golden_diff": "diff --git a/dvc/repo/experiments/executor/local.py b/dvc/repo/experiments/executor/local.py\n--- a/dvc/repo/experiments/executor/local.py\n+++ b/dvc/repo/experiments/executor/local.py\n@@ -1,6 +1,5 @@\n import logging\n import os\n-import sys\n from tempfile import TemporaryDirectory\n from typing import Optional\n \n@@ -56,11 +55,4 @@\n     def cleanup(self):\n         super().cleanup()\n         logger.debug(\"Removing tmpdir '%s'\", self._tmp_dir)\n-        try:\n-            self._tmp_dir.cleanup()\n-        except PermissionError:\n-            if os.name == \"nt\" and sys.version_info < (3, 8):\n-                # see https://bugs.python.org/issue26660\n-                remove(self._tmp_dir.name)\n-                return\n-            raise\n+        remove(self._tmp_dir.name)\n", "issue": "tests: exp executor teardown is flaky on windows\nLooks like there is some race condition on windows that sometimes happens between cleaning up the test `tmp_dir` and cleaning up the experiments executor temp directory (which is placed in `tmp_dir/.dvc/tmp/...`). May be better to go back to running experiments in system `$TEMP` instead of `.dvc/tmp` (for win tests only)?\n", "before_files": [{"content": "import logging\nimport os\nimport sys\nfrom tempfile import TemporaryDirectory\nfrom typing import Optional\n\nfrom dvc.utils.fs import remove\n\nfrom .base import BaseExecutor\n\nlogger = logging.getLogger(__name__)\n\n\nclass BaseLocalExecutor(BaseExecutor):\n    \"\"\"Base local machine executor.\"\"\"\n\n    @property\n    def git_url(self) -> str:\n        root_dir = os.path.abspath(self.root_dir)\n        if os.name == \"nt\":\n            root_dir = root_dir.replace(os.sep, \"/\")\n        return f\"file://{root_dir}\"\n\n\nclass TempDirExecutor(BaseLocalExecutor):\n    \"\"\"Temp directory experiment executor.\"\"\"\n\n    # Temp dir executors should warn if untracked files exist (to help with\n    # debugging user code), and suppress other DVC hints (like `git add`\n    # suggestions) that are not applicable outside of workspace runs\n    WARN_UNTRACKED = True\n    QUIET = True\n\n    def __init__(\n        self,\n        *args,\n        tmp_dir: Optional[str] = None,\n        cache_dir: Optional[str] = None,\n        **kwargs,\n    ):\n        self._tmp_dir = TemporaryDirectory(dir=tmp_dir)\n        kwargs[\"root_dir\"] = self._tmp_dir.name\n        super().__init__(*args, **kwargs)\n        if cache_dir:\n            self._config(cache_dir)\n        logger.debug(\n            \"Init temp dir executor in dir '%s'\", self._tmp_dir,\n        )\n\n    def _config(self, cache_dir):\n        local_config = os.path.join(self.dvc_dir, \"config.local\")\n        logger.debug(\"Writing experiments local config '%s'\", local_config)\n        with open(local_config, \"w\") as fobj:\n            fobj.write(f\"[cache]\\n    dir = {cache_dir}\")\n\n    def cleanup(self):\n        super().cleanup()\n        logger.debug(\"Removing tmpdir '%s'\", self._tmp_dir)\n        try:\n            self._tmp_dir.cleanup()\n        except PermissionError:\n            if os.name == \"nt\" and sys.version_info < (3, 8):\n                # see https://bugs.python.org/issue26660\n                remove(self._tmp_dir.name)\n                return\n            raise\n", "path": "dvc/repo/experiments/executor/local.py"}], "after_files": [{"content": "import logging\nimport os\nfrom tempfile import TemporaryDirectory\nfrom typing import Optional\n\nfrom dvc.utils.fs import remove\n\nfrom .base import BaseExecutor\n\nlogger = logging.getLogger(__name__)\n\n\nclass BaseLocalExecutor(BaseExecutor):\n    \"\"\"Base local machine executor.\"\"\"\n\n    @property\n    def git_url(self) -> str:\n        root_dir = os.path.abspath(self.root_dir)\n        if os.name == \"nt\":\n            root_dir = root_dir.replace(os.sep, \"/\")\n        return f\"file://{root_dir}\"\n\n\nclass TempDirExecutor(BaseLocalExecutor):\n    \"\"\"Temp directory experiment executor.\"\"\"\n\n    # Temp dir executors should warn if untracked files exist (to help with\n    # debugging user code), and suppress other DVC hints (like `git add`\n    # suggestions) that are not applicable outside of workspace runs\n    WARN_UNTRACKED = True\n    QUIET = True\n\n    def __init__(\n        self,\n        *args,\n        tmp_dir: Optional[str] = None,\n        cache_dir: Optional[str] = None,\n        **kwargs,\n    ):\n        self._tmp_dir = TemporaryDirectory(dir=tmp_dir)\n        kwargs[\"root_dir\"] = self._tmp_dir.name\n        super().__init__(*args, **kwargs)\n        if cache_dir:\n            self._config(cache_dir)\n        logger.debug(\n            \"Init temp dir executor in dir '%s'\", self._tmp_dir,\n        )\n\n    def _config(self, cache_dir):\n        local_config = os.path.join(self.dvc_dir, \"config.local\")\n        logger.debug(\"Writing experiments local config '%s'\", local_config)\n        with open(local_config, \"w\") as fobj:\n            fobj.write(f\"[cache]\\n    dir = {cache_dir}\")\n\n    def cleanup(self):\n        super().cleanup()\n        logger.debug(\"Removing tmpdir '%s'\", self._tmp_dir)\n        remove(self._tmp_dir.name)\n", "path": "dvc/repo/experiments/executor/local.py"}]}