Add support for user-defined server timeout setting (#492)
This commit is contained in:
@@ -3,6 +3,7 @@ import urlparse
|
||||
import socket
|
||||
import thread
|
||||
import wx
|
||||
from service.settings import CRESTSettings
|
||||
|
||||
import logging
|
||||
|
||||
@@ -55,8 +56,11 @@ class StoppableHTTPServer(BaseHTTPServer.HTTPServer):
|
||||
|
||||
def server_bind(self):
|
||||
BaseHTTPServer.HTTPServer.server_bind(self)
|
||||
# Allow listening for 60 seconds
|
||||
sec = 60
|
||||
self.settings = CRESTSettings.getInstance()
|
||||
|
||||
# Allow listening for x seconds
|
||||
sec = self.settings.get('timeout')
|
||||
logger.debug("Running server for %d seconds", sec)
|
||||
|
||||
self.socket.settimeout(0.5)
|
||||
self.max_tries = sec / self.socket.gettimeout()
|
||||
|
||||
@@ -278,7 +278,7 @@ class CRESTSettings():
|
||||
# mode
|
||||
# 0 - Implicit authentication
|
||||
# 1 - User-supplied client details
|
||||
serviceCRESTDefaultSettings = {"mode": 0, "server": 0, "clientID": "", "clientSecret": ""}
|
||||
serviceCRESTDefaultSettings = {"mode": 0, "server": 0, "clientID": "", "clientSecret": "", "timeout": 60}
|
||||
|
||||
self.serviceCRESTSettings = SettingsProvider.getInstance().getSettings("pyfaServiceCRESTSettings", serviceCRESTDefaultSettings)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user