prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Using Ctrl+C causes launcher to print traceback
  ## Environment data
  
  - PTVSD version: master
  - OS and version: linux
  - Python version (& distribution if applicable, e.g. Anaconda): 3.7
  - Using VS Code or Visual Studio: VSC
  
  ## Actual behavior
  
  ```console
  Traceback (most recent call last):
    File "/usr/lib/python3.7/runpy.py", line 193, in _run_module_as_main
      "__main__", mod_spec)
    File "/usr/lib/python3.7/runpy.py", line 85, in _run_code
      exec(code, run_globals)
    File "/home/kanadig/GIT/ptvsd/src/ptvsd/launcher/__main__.py", line 74, in <module>
      main()
    File "/home/kanadig/GIT/ptvsd/src/ptvsd/launcher/__main__.py", line 37, in main
      adapter.channel.wait()
    File "/home/kanadig/GIT/ptvsd/src/ptvsd/launcher/../../ptvsd/common/messaging.py", line 1231, in wait
      parser_thread.join()
    File "/usr/lib/python3.7/threading.py", line 1032, in join
      self._wait_for_tstate_lock()
    File "/usr/lib/python3.7/threading.py", line 1048, in _wait_for_tstate_lock
      elif lock.acquire(block, timeout):
  KeyboardInterrupt
  ```
  
  ## Expected  behavior
  
  This is normal way to shutdown the servers. Show not print exception in launcher.
  
  
  
  --- 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/ptvsd/launcher/__main__.py`
  Content:
  ```
  1 # Copyright (c) Microsoft Corporation. All rights reserved.
  2 # Licensed under the MIT License. See LICENSE in the project root
  3 # for license information.
  4 
  5 from __future__ import absolute_import, division, print_function, unicode_literals
  6 
  7 __all__ = ["main"]
  8 
  9 import locale
  10 import os
  11 import sys
  12 
  13 # WARNING: ptvsd and submodules must not be imported on top level in this module,
  14 # and should be imported locally inside main() instead.
  15 
  16 # Force absolute path on Python 2.
  17 __file__ = os.path.abspath(__file__)
  18 
  19 
  20 def main():
  21     from ptvsd.common import log
  22     from ptvsd import launcher
  23     from ptvsd.launcher import debuggee
  24 
  25     log.to_file(prefix="ptvsd.launcher")
  26     log.describe_environment("ptvsd.launcher startup environment:")
  27 
  28     def option(name, type, *args):
  29         try:
  30             return type(os.environ.pop(name, *args))
  31         except Exception:
  32             raise log.exception("Error parsing {0!r}:", name)
  33 
  34     launcher_port = option("PTVSD_LAUNCHER_PORT", int)
  35 
  36     launcher.connect(launcher_port)
  37     launcher.channel.wait()
  38 
  39     if debuggee.process is not None:
  40         sys.exit(debuggee.process.returncode)
  41 
  42 
  43 if __name__ == "__main__":
  44     # ptvsd can also be invoked directly rather than via -m. In this case, the first
  45     # entry on sys.path is the one added automatically by Python for the directory
  46     # containing this file. This means that import ptvsd will not work, since we need
  47     # the parent directory of ptvsd/ to be in sys.path, rather than ptvsd/launcher/.
  48     #
  49     # The other issue is that many other absolute imports will break, because they
  50     # will be resolved relative to ptvsd/launcher/ - e.g. `import state` will then try
  51     # to import ptvsd/launcher/state.py.
  52     #
  53     # To fix both, we need to replace the automatically added entry such that it points
  54     # at parent directory of ptvsd/ instead of ptvsd/launcher, import ptvsd with that
  55     # in sys.path, and then remove the first entry entry altogether, so that it doesn't
  56     # affect any further imports we might do. For example, suppose the user did:
  57     #
  58     #   python /foo/bar/ptvsd/launcher ...
  59     #
  60     # At the beginning of this script, sys.path will contain "/foo/bar/ptvsd/launcher"
  61     # as the first entry. What we want is to replace it with "/foo/bar', then import
  62     # ptvsd with that in effect, and then remove the replaced entry before any more
  63     # code runs. The imported ptvsd module will remain in sys.modules, and thus all
  64     # future imports of it or its submodules will resolve accordingly.
  65     if "ptvsd" not in sys.modules:
  66         # Do not use dirname() to walk up - this can be a relative path, e.g. ".".
  67         sys.path[0] = sys.path[0] + "/../../"
  68         __import__("ptvsd")
  69         del sys.path[0]
  70 
  71     # Load locale settings.
  72     locale.setlocale(locale.LC_ALL, "")
  73 
  74     main()
  75
  ```
  --- 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/src/ptvsd/launcher/__main__.py b/src/ptvsd/launcher/__main__.py
  --- a/src/ptvsd/launcher/__main__.py
  +++ b/src/ptvsd/launcher/__main__.py
  @@ -8,6 +8,7 @@
   
   import locale
   import os
  +import signal
   import sys
   
   # WARNING: ptvsd and submodules must not be imported on top level in this module,
  @@ -25,6 +26,11 @@
       log.to_file(prefix="ptvsd.launcher")
       log.describe_environment("ptvsd.launcher startup environment:")
   
  +    # Disable exceptions on Ctrl+C - we want to allow the debuggee process to handle
  +    # these, or not, as it sees fit. If the debuggee exits on Ctrl+C, the launcher
  +    # will also exit, so it doesn't need to observe the signal directly.
  +    signal.signal(signal.SIGINT, signal.SIG_IGN)
  +
       def option(name, type, *args):
           try:
               return type(os.environ.pop(name, *args))
  
verification_info: {"golden_diff": "diff --git a/src/ptvsd/launcher/__main__.py b/src/ptvsd/launcher/__main__.py\n--- a/src/ptvsd/launcher/__main__.py\n+++ b/src/ptvsd/launcher/__main__.py\n@@ -8,6 +8,7 @@\n \n import locale\n import os\n+import signal\n import sys\n \n # WARNING: ptvsd and submodules must not be imported on top level in this module,\n@@ -25,6 +26,11 @@\n     log.to_file(prefix=\"ptvsd.launcher\")\n     log.describe_environment(\"ptvsd.launcher startup environment:\")\n \n+    # Disable exceptions on Ctrl+C - we want to allow the debuggee process to handle\n+    # these, or not, as it sees fit. If the debuggee exits on Ctrl+C, the launcher\n+    # will also exit, so it doesn't need to observe the signal directly.\n+    signal.signal(signal.SIGINT, signal.SIG_IGN)\n+\n     def option(name, type, *args):\n         try:\n             return type(os.environ.pop(name, *args))\n", "issue": "Using Ctrl+C causes launcher to print traceback\n## Environment data\r\n\r\n- PTVSD version: master\r\n- OS and version: linux\r\n- Python version (& distribution if applicable, e.g. Anaconda): 3.7\r\n- Using VS Code or Visual Studio: VSC\r\n\r\n## Actual behavior\r\n\r\n```console\r\nTraceback (most recent call last):\r\n  File \"/usr/lib/python3.7/runpy.py\", line 193, in _run_module_as_main\r\n    \"__main__\", mod_spec)\r\n  File \"/usr/lib/python3.7/runpy.py\", line 85, in _run_code\r\n    exec(code, run_globals)\r\n  File \"/home/kanadig/GIT/ptvsd/src/ptvsd/launcher/__main__.py\", line 74, in <module>\r\n    main()\r\n  File \"/home/kanadig/GIT/ptvsd/src/ptvsd/launcher/__main__.py\", line 37, in main\r\n    adapter.channel.wait()\r\n  File \"/home/kanadig/GIT/ptvsd/src/ptvsd/launcher/../../ptvsd/common/messaging.py\", line 1231, in wait\r\n    parser_thread.join()\r\n  File \"/usr/lib/python3.7/threading.py\", line 1032, in join\r\n    self._wait_for_tstate_lock()\r\n  File \"/usr/lib/python3.7/threading.py\", line 1048, in _wait_for_tstate_lock\r\n    elif lock.acquire(block, timeout):\r\nKeyboardInterrupt\r\n```\r\n\r\n## Expected  behavior\r\n\r\nThis is normal way to shutdown the servers. Show not print exception in launcher.\r\n\r\n\n", "before_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License. See LICENSE in the project root\n# for license information.\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\n__all__ = [\"main\"]\n\nimport locale\nimport os\nimport sys\n\n# WARNING: ptvsd and submodules must not be imported on top level in this module,\n# and should be imported locally inside main() instead.\n\n# Force absolute path on Python 2.\n__file__ = os.path.abspath(__file__)\n\n\ndef main():\n    from ptvsd.common import log\n    from ptvsd import launcher\n    from ptvsd.launcher import debuggee\n\n    log.to_file(prefix=\"ptvsd.launcher\")\n    log.describe_environment(\"ptvsd.launcher startup environment:\")\n\n    def option(name, type, *args):\n        try:\n            return type(os.environ.pop(name, *args))\n        except Exception:\n            raise log.exception(\"Error parsing {0!r}:\", name)\n\n    launcher_port = option(\"PTVSD_LAUNCHER_PORT\", int)\n\n    launcher.connect(launcher_port)\n    launcher.channel.wait()\n\n    if debuggee.process is not None:\n        sys.exit(debuggee.process.returncode)\n\n\nif __name__ == \"__main__\":\n    # ptvsd can also be invoked directly rather than via -m. In this case, the first\n    # entry on sys.path is the one added automatically by Python for the directory\n    # containing this file. This means that import ptvsd will not work, since we need\n    # the parent directory of ptvsd/ to be in sys.path, rather than ptvsd/launcher/.\n    #\n    # The other issue is that many other absolute imports will break, because they\n    # will be resolved relative to ptvsd/launcher/ - e.g. `import state` will then try\n    # to import ptvsd/launcher/state.py.\n    #\n    # To fix both, we need to replace the automatically added entry such that it points\n    # at parent directory of ptvsd/ instead of ptvsd/launcher, import ptvsd with that\n    # in sys.path, and then remove the first entry entry altogether, so that it doesn't\n    # affect any further imports we might do. For example, suppose the user did:\n    #\n    #   python /foo/bar/ptvsd/launcher ...\n    #\n    # At the beginning of this script, sys.path will contain \"/foo/bar/ptvsd/launcher\"\n    # as the first entry. What we want is to replace it with \"/foo/bar', then import\n    # ptvsd with that in effect, and then remove the replaced entry before any more\n    # code runs. The imported ptvsd module will remain in sys.modules, and thus all\n    # future imports of it or its submodules will resolve accordingly.\n    if \"ptvsd\" not in sys.modules:\n        # Do not use dirname() to walk up - this can be a relative path, e.g. \".\".\n        sys.path[0] = sys.path[0] + \"/../../\"\n        __import__(\"ptvsd\")\n        del sys.path[0]\n\n    # Load locale settings.\n    locale.setlocale(locale.LC_ALL, \"\")\n\n    main()\n", "path": "src/ptvsd/launcher/__main__.py"}], "after_files": [{"content": "# Copyright (c) Microsoft Corporation. All rights reserved.\n# Licensed under the MIT License. See LICENSE in the project root\n# for license information.\n\nfrom __future__ import absolute_import, division, print_function, unicode_literals\n\n__all__ = [\"main\"]\n\nimport locale\nimport os\nimport signal\nimport sys\n\n# WARNING: ptvsd and submodules must not be imported on top level in this module,\n# and should be imported locally inside main() instead.\n\n# Force absolute path on Python 2.\n__file__ = os.path.abspath(__file__)\n\n\ndef main():\n    from ptvsd.common import log\n    from ptvsd import launcher\n    from ptvsd.launcher import debuggee\n\n    log.to_file(prefix=\"ptvsd.launcher\")\n    log.describe_environment(\"ptvsd.launcher startup environment:\")\n\n    # Disable exceptions on Ctrl+C - we want to allow the debuggee process to handle\n    # these, or not, as it sees fit. If the debuggee exits on Ctrl+C, the launcher\n    # will also exit, so it doesn't need to observe the signal directly.\n    signal.signal(signal.SIGINT, signal.SIG_IGN)\n\n    def option(name, type, *args):\n        try:\n            return type(os.environ.pop(name, *args))\n        except Exception:\n            raise log.exception(\"Error parsing {0!r}:\", name)\n\n    launcher_port = option(\"PTVSD_LAUNCHER_PORT\", int)\n\n    launcher.connect(launcher_port)\n    launcher.channel.wait()\n\n    if debuggee.process is not None:\n        sys.exit(debuggee.process.returncode)\n\n\nif __name__ == \"__main__\":\n    # ptvsd can also be invoked directly rather than via -m. In this case, the first\n    # entry on sys.path is the one added automatically by Python for the directory\n    # containing this file. This means that import ptvsd will not work, since we need\n    # the parent directory of ptvsd/ to be in sys.path, rather than ptvsd/launcher/.\n    #\n    # The other issue is that many other absolute imports will break, because they\n    # will be resolved relative to ptvsd/launcher/ - e.g. `import state` will then try\n    # to import ptvsd/launcher/state.py.\n    #\n    # To fix both, we need to replace the automatically added entry such that it points\n    # at parent directory of ptvsd/ instead of ptvsd/launcher, import ptvsd with that\n    # in sys.path, and then remove the first entry entry altogether, so that it doesn't\n    # affect any further imports we might do. For example, suppose the user did:\n    #\n    #   python /foo/bar/ptvsd/launcher ...\n    #\n    # At the beginning of this script, sys.path will contain \"/foo/bar/ptvsd/launcher\"\n    # as the first entry. What we want is to replace it with \"/foo/bar', then import\n    # ptvsd with that in effect, and then remove the replaced entry before any more\n    # code runs. The imported ptvsd module will remain in sys.modules, and thus all\n    # future imports of it or its submodules will resolve accordingly.\n    if \"ptvsd\" not in sys.modules:\n        # Do not use dirname() to walk up - this can be a relative path, e.g. \".\".\n        sys.path[0] = sys.path[0] + \"/../../\"\n        __import__(\"ptvsd\")\n        del sys.path[0]\n\n    # Load locale settings.\n    locale.setlocale(locale.LC_ALL, \"\")\n\n    main()\n", "path": "src/ptvsd/launcher/__main__.py"}]}