prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  [Bug] system.exit(code) is not respected in Hydra
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `hydra/main.py`
  Content:
  ```
  1 # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
  2 import functools
  3 import sys
  4 from typing import Callable, Optional
  5 
  6 from ._internal.utils import get_args_parser, run_hydra
  7 from .types import TaskFunction
  8 
  9 # TODO: change config_path to Optional[str]
  10 
  11 
  12 def main(
  13     config_path: str = "", strict: Optional[bool] = None
  14 ) -> Callable[[TaskFunction], Callable[[], None]]:
  15     """
  16     :param config_path: the config path, can be a directory in which it's used as the config root
  17     or a file to load
  18     :param strict: strict mode, will throw an error if command line overrides are not changing an
  19     existing key or
  20            if the code is accessing a non existent key
  21     """
  22 
  23     def main_decorator(task_function: TaskFunction) -> Callable[[], None]:
  24         @functools.wraps(task_function)
  25         def decorated_main() -> None:
  26             try:
  27                 run_hydra(
  28                     args_parser=get_args_parser(),
  29                     task_function=task_function,
  30                     config_path=config_path,
  31                     strict=strict,
  32                 )
  33             except KeyboardInterrupt:
  34                 sys.exit(-1)
  35             except SystemExit:
  36                 pass
  37 
  38         return decorated_main
  39 
  40     return main_decorator
  41
  ```
  --- 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/hydra/main.py b/hydra/main.py
  --- a/hydra/main.py
  +++ b/hydra/main.py
  @@ -1,6 +1,5 @@
   # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved
   import functools
  -import sys
   from typing import Callable, Optional
   
   from ._internal.utils import get_args_parser, run_hydra
  @@ -23,17 +22,12 @@
       def main_decorator(task_function: TaskFunction) -> Callable[[], None]:
           @functools.wraps(task_function)
           def decorated_main() -> None:
  -            try:
  -                run_hydra(
  -                    args_parser=get_args_parser(),
  -                    task_function=task_function,
  -                    config_path=config_path,
  -                    strict=strict,
  -                )
  -            except KeyboardInterrupt:
  -                sys.exit(-1)
  -            except SystemExit:
  -                pass
  +            run_hydra(
  +                args_parser=get_args_parser(),
  +                task_function=task_function,
  +                config_path=config_path,
  +                strict=strict,
  +            )
   
           return decorated_main
  
verification_info: {"golden_diff": "diff --git a/hydra/main.py b/hydra/main.py\n--- a/hydra/main.py\n+++ b/hydra/main.py\n@@ -1,6 +1,5 @@\n # Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\n import functools\n-import sys\n from typing import Callable, Optional\n \n from ._internal.utils import get_args_parser, run_hydra\n@@ -23,17 +22,12 @@\n     def main_decorator(task_function: TaskFunction) -> Callable[[], None]:\n         @functools.wraps(task_function)\n         def decorated_main() -> None:\n-            try:\n-                run_hydra(\n-                    args_parser=get_args_parser(),\n-                    task_function=task_function,\n-                    config_path=config_path,\n-                    strict=strict,\n-                )\n-            except KeyboardInterrupt:\n-                sys.exit(-1)\n-            except SystemExit:\n-                pass\n+            run_hydra(\n+                args_parser=get_args_parser(),\n+                task_function=task_function,\n+                config_path=config_path,\n+                strict=strict,\n+            )\n \n         return decorated_main\n", "issue": "[Bug] system.exit(code) is not respected in Hydra\n\n", "before_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport functools\nimport sys\nfrom typing import Callable, Optional\n\nfrom ._internal.utils import get_args_parser, run_hydra\nfrom .types import TaskFunction\n\n# TODO: change config_path to Optional[str]\n\n\ndef main(\n    config_path: str = \"\", strict: Optional[bool] = None\n) -> Callable[[TaskFunction], Callable[[], None]]:\n    \"\"\"\n    :param config_path: the config path, can be a directory in which it's used as the config root\n    or a file to load\n    :param strict: strict mode, will throw an error if command line overrides are not changing an\n    existing key or\n           if the code is accessing a non existent key\n    \"\"\"\n\n    def main_decorator(task_function: TaskFunction) -> Callable[[], None]:\n        @functools.wraps(task_function)\n        def decorated_main() -> None:\n            try:\n                run_hydra(\n                    args_parser=get_args_parser(),\n                    task_function=task_function,\n                    config_path=config_path,\n                    strict=strict,\n                )\n            except KeyboardInterrupt:\n                sys.exit(-1)\n            except SystemExit:\n                pass\n\n        return decorated_main\n\n    return main_decorator\n", "path": "hydra/main.py"}], "after_files": [{"content": "# Copyright (c) Facebook, Inc. and its affiliates. All Rights Reserved\nimport functools\nfrom typing import Callable, Optional\n\nfrom ._internal.utils import get_args_parser, run_hydra\nfrom .types import TaskFunction\n\n# TODO: change config_path to Optional[str]\n\n\ndef main(\n    config_path: str = \"\", strict: Optional[bool] = None\n) -> Callable[[TaskFunction], Callable[[], None]]:\n    \"\"\"\n    :param config_path: the config path, can be a directory in which it's used as the config root\n    or a file to load\n    :param strict: strict mode, will throw an error if command line overrides are not changing an\n    existing key or\n           if the code is accessing a non existent key\n    \"\"\"\n\n    def main_decorator(task_function: TaskFunction) -> Callable[[], None]:\n        @functools.wraps(task_function)\n        def decorated_main() -> None:\n            run_hydra(\n                args_parser=get_args_parser(),\n                task_function=task_function,\n                config_path=config_path,\n                strict=strict,\n            )\n\n        return decorated_main\n\n    return main_decorator\n", "path": "hydra/main.py"}]}