#88 - ignore BrokenPipeError
This commit is contained in:
parent
27e0b30541
commit
dab22737c7
1 changed files with 37 additions and 7 deletions
|
@ -275,8 +275,13 @@ class ManageHttpRequest(http.server.SimpleHTTPRequestHandler):
|
|||
return
|
||||
self.server.listSemaphore[name].release()
|
||||
self._set_headers()
|
||||
try:
|
||||
self.wfile.write(bytes(json.dumps(item), "utf-8"))
|
||||
logging.debug("item : %s" % item)
|
||||
except BrokenPipeError:
|
||||
# ignore BrokenPipeError: [Errno 32] Broken pipe
|
||||
logging.debug("BrokenPipeError detected")
|
||||
pass
|
||||
|
||||
def _send_list(self):
|
||||
""" sub-request to list all program available """
|
||||
|
@ -286,7 +291,12 @@ class ManageHttpRequest(http.server.SimpleHTTPRequestHandler):
|
|||
outjson.setdefault(pos, program)
|
||||
pos += 1
|
||||
self._set_headers()
|
||||
try:
|
||||
self.wfile.write(bytes(json.dumps(outjson), "utf-8"))
|
||||
except BrokenPipeError:
|
||||
# ignore BrokenPipeError: [Errno 32] Broken pipe
|
||||
logging.debug("BrokenPipeError detected")
|
||||
pass
|
||||
|
||||
def _send_shutdown(self):
|
||||
""" Stop all program and stop manager """
|
||||
|
@ -296,7 +306,12 @@ class ManageHttpRequest(http.server.SimpleHTTPRequestHandler):
|
|||
self.server.listSemaphore[name].release()
|
||||
self._set_headers()
|
||||
outjson = {'shutdown': 'ok'}
|
||||
try:
|
||||
self.wfile.write(bytes(json.dumps(outjson), "utf-8"))
|
||||
except BrokenPipeError:
|
||||
# ignore BrokenPipeError: [Errno 32] Broken pipe
|
||||
logging.debug("BrokenPipeError detected")
|
||||
pass
|
||||
|
||||
def _send_command_all(self, command):
|
||||
""" Send specific command on all program
|
||||
|
@ -315,7 +330,12 @@ class ManageHttpRequest(http.server.SimpleHTTPRequestHandler):
|
|||
self.server.listSemaphore[name].release()
|
||||
outjson.setdefault(name, item)
|
||||
self._set_headers()
|
||||
try:
|
||||
self.wfile.write(bytes(json.dumps(outjson), "utf-8"))
|
||||
except BrokenPipeError:
|
||||
# ignore BrokenPipeError: [Errno 32] Broken pipe
|
||||
logging.debug("BrokenPipeError detected")
|
||||
pass
|
||||
|
||||
def _send_action(self):
|
||||
""" send specific action on one program """
|
||||
|
@ -359,7 +379,12 @@ class ManageHttpRequest(http.server.SimpleHTTPRequestHandler):
|
|||
return
|
||||
self.server.listSemaphore[name].release()
|
||||
self._set_headers()
|
||||
try:
|
||||
self.wfile.write(bytes(json.dumps(outjson), "utf-8"))
|
||||
except BrokenPipeError:
|
||||
# ignore BrokenPipeError: [Errno 32] Broken pipe
|
||||
logging.debug("BrokenPipeError detected")
|
||||
pass
|
||||
|
||||
def _send_command(self, command):
|
||||
""" Send specific command on one program
|
||||
|
@ -398,7 +423,12 @@ class ManageHttpRequest(http.server.SimpleHTTPRequestHandler):
|
|||
self.server.listSemaphore[name].release()
|
||||
logging.debug("[%s %s] => %s" % (command, name, outjson))
|
||||
self._set_headers()
|
||||
try:
|
||||
self.wfile.write(bytes(json.dumps(outjson), "utf-8"))
|
||||
except BrokenPipeError:
|
||||
# ignore BrokenPipeError: [Errno 32] Broken pipe
|
||||
logging.debug("BrokenPipeError detected")
|
||||
pass
|
||||
|
||||
def check_authentication(self):
|
||||
if not self.server.authentification:
|
||||
|
|
Loading…
Reference in a new issue