Browse Source

Significantly reduce startuptime by lowering CP check_port timeout

pull/745/head
Safihre 9 years ago
parent
commit
a922da5868
  1. 13
      SABnzbd.py

13
SABnzbd.py

@ -57,7 +57,6 @@ if [int(n) for n in cherrypy.__version__.split('.')] < [8, 1, 2]:
sys.exit(1) sys.exit(1)
from cherrypy import _cpserver from cherrypy import _cpserver
from cherrypy import _cpwsgi_server
SQLITE_DLL = True SQLITE_DLL = True
try: try:
@ -709,7 +708,7 @@ def find_free_port(host, currentport):
n = 0 n = 0
while n < 10 and currentport <= 49151: while n < 10 and currentport <= 49151:
try: try:
cherrypy.process.servers.check_port(host, currentport) cherrypy.process.servers.check_port(host, currentport, timeout=0.1)
return currentport return currentport
except: except:
currentport += 5 currentport += 5
@ -1072,13 +1071,13 @@ def main():
if sabnzbd.DAEMON: if sabnzbd.DAEMON:
if enable_https and https_port: if enable_https and https_port:
try: try:
cherrypy.process.servers.check_port(cherryhost, https_port) cherrypy.process.servers.check_port(cherryhost, https_port, timeout=0.1)
except IOError, error: except IOError, error:
Bail_Out(browserhost, cherryport) Bail_Out(browserhost, cherryport)
except: except:
Bail_Out(browserhost, cherryport, '49') Bail_Out(browserhost, cherryport, '49')
try: try:
cherrypy.process.servers.check_port(cherryhost, cherryport) cherrypy.process.servers.check_port(cherryhost, cherryport, timeout=0.1)
except IOError, error: except IOError, error:
Bail_Out(browserhost, cherryport) Bail_Out(browserhost, cherryport)
except: except:
@ -1100,7 +1099,7 @@ def main():
if enable_https: if enable_https:
port = https_port or cherryport port = https_port or cherryport
try: try:
cherrypy.process.servers.check_port(browserhost, port) cherrypy.process.servers.check_port(browserhost, port, timeout=0.1)
except IOError, error: except IOError, error:
if str(error) == 'Port not bound.': if str(error) == 'Port not bound.':
pass pass
@ -1122,7 +1121,7 @@ def main():
# NonSSL # NonSSL
try: try:
cherrypy.process.servers.check_port(browserhost, cherryport) cherrypy.process.servers.check_port(browserhost, cherryport, timeout=0.1)
except IOError, error: except IOError, error:
if str(error) == 'Port not bound.': if str(error) == 'Port not bound.':
pass pass
@ -1512,7 +1511,7 @@ def main():
try: try:
# Use internal cherrypy check first to prevent ugly tracebacks # Use internal cherrypy check first to prevent ugly tracebacks
cherrypy.process.servers.check_port(browserhost, cherryport) cherrypy.process.servers.check_port(browserhost, cherryport, timeout=0.1)
cherrypy.engine.start() cherrypy.engine.start()
except IOError, error: except IOError, error:
if str(error) == 'Port not bound.': if str(error) == 'Port not bound.':

Loading…
Cancel
Save