Catch interrupted system call

Closes #166
This commit is contained in:
Bennett Kanuka 2015-04-04 20:11:13 -04:00 committed by Solly Ross
parent 2544dd3aaf
commit edcbfcb9eb

View File

@ -11,12 +11,12 @@ as taken from http://docs.python.org/dev/library/ssl.html#certificates
'''
import signal, socket, optparse, time, os, sys, subprocess, logging
import signal, socket, optparse, time, os, sys, subprocess, logging, errno
try: from socketserver import ForkingMixIn
except: from SocketServer import ForkingMixIn
try: from http.server import HTTPServer
except: from BaseHTTPServer import HTTPServer
from select import select
import select
from websockify import websocket
try:
from urllib.parse import parse_qs, urlparse
@ -133,7 +133,20 @@ Traffic Legend:
if tqueue: wlist.append(target)
if cqueue or c_pend: wlist.append(self.request)
ins, outs, excepts = select(rlist, wlist, [], 1)
try:
ins, outs, excepts = select.select(rlist, wlist, [], 1)
except (select.error, OSError):
exc = sys.exc_info()[1]
if hasattr(exc, 'errno'):
err = exc.errno
else:
err = exc[0]
if err != errno.EINTR:
raise
else:
continue
if excepts: raise Exception("Socket exception")
if self.request in outs: