From f77afe8faee8585b69021906e5e1bbd0a8f86e48 Mon Sep 17 00:00:00 2001 From: mailchuck Date: Mon, 23 Nov 2015 01:35:11 +0100 Subject: [PATCH] Exception handling --- src/upnp.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/upnp.py b/src/upnp.py index fdff04a5..abfe9e65 100644 --- a/src/upnp.py +++ b/src/upnp.py @@ -206,8 +206,14 @@ class uPnPThread(threading.Thread, StoppableThread): for router in self.routers: if router.extPort is None: self.createPortMapping(router) - self.sock.shutdown(socket.SHUT_RDWR) - self.sock.close() + try: + self.sock.shutdown(socket.SHUT_RDWR) + except: + pass + try: + self.sock.close() + except: + pass deleted = False for router in self.routers: if router.extPort is not None: