From d86fbfffc3f646b1ebd4a37ca052cb63437509f0 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 6449b7fd..e14d1100 100644 --- a/src/upnp.py +++ b/src/upnp.py @@ -214,8 +214,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: