pywebsocket_wrapper.py 877 B

1234567891011121314151617181920212223242526272829
  1. #
  2. # This Source Code Form is subject to the terms of the Mozilla Public
  3. # License, v. 2.0. If a copy of the MPL was not distributed with this
  4. # file, You can obtain one at http://mozilla.org/MPL/2.0/.
  5. #
  6. """A wrapper around pywebsocket's standalone.py which causes it to ignore
  7. SIGINT.
  8. """
  9. import signal
  10. import sys
  11. if __name__ == '__main__':
  12. sys.path = ['pywebsocket'] + sys.path
  13. import standalone
  14. # If we received --interactive as the first argument, ignore SIGINT so
  15. # pywebsocket doesn't die on a ctrl+c meant for the debugger. Otherwise,
  16. # die immediately on SIGINT so we don't print a messy backtrace.
  17. if len(sys.argv) >= 2 and sys.argv[1] == '--interactive':
  18. del sys.argv[1]
  19. signal.signal(signal.SIGINT, signal.SIG_IGN)
  20. else:
  21. signal.signal(signal.SIGINT, lambda signum, frame: sys.exit(1))
  22. standalone._main()