1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/testing/mochitest/pywebsocket_wrapper.py Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,28 @@ 1.4 +# 1.5 +# This Source Code Form is subject to the terms of the Mozilla Public 1.6 +# License, v. 2.0. If a copy of the MPL was not distributed with this 1.7 +# file, You can obtain one at http://mozilla.org/MPL/2.0/. 1.8 +# 1.9 + 1.10 +"""A wrapper around pywebsocket's standalone.py which causes it to ignore 1.11 +SIGINT. 1.12 + 1.13 +""" 1.14 + 1.15 +import signal 1.16 +import sys 1.17 + 1.18 +if __name__ == '__main__': 1.19 + sys.path = ['pywebsocket'] + sys.path 1.20 + import standalone 1.21 + 1.22 + # If we received --interactive as the first argument, ignore SIGINT so 1.23 + # pywebsocket doesn't die on a ctrl+c meant for the debugger. Otherwise, 1.24 + # die immediately on SIGINT so we don't print a messy backtrace. 1.25 + if len(sys.argv) >= 2 and sys.argv[1] == '--interactive': 1.26 + del sys.argv[1] 1.27 + signal.signal(signal.SIGINT, signal.SIG_IGN) 1.28 + else: 1.29 + signal.signal(signal.SIGINT, lambda signum, frame: sys.exit(1)) 1.30 + 1.31 + standalone._main()