Browse Source

Revert "[1828] Cleanup code by using with"

This reverts commit 9040c49022e84e7b1398e84a14abd54f8d99ec8c.
Mukund Sivaraman 13 years ago
parent
commit
e8d6a1ad9b
1 changed files with 9 additions and 7 deletions
  1. 9 7
      src/bin/xfrout/xfrout.py.in

+ 9 - 7
src/bin/xfrout/xfrout.py.in

@@ -804,13 +804,15 @@ class UnixSockServer(socketserver_mixin.NoPollMixIn,
         '''Check whether the socket file 'sock_file' exists and
         '''Check whether the socket file 'sock_file' exists and
         is being used by one running xfrout process. If it is,
         is being used by one running xfrout process. If it is,
         return True, or else return False. '''
         return True, or else return False. '''
-        with socket.socket(socket.AF_UNIX) as sock:
-            try:
-                sock.connect(sock_file)
-            except socket.error as err:
-                return False
-            else:
-                return True
+        try:
+            sock = socket.socket(socket.AF_UNIX)
+            sock.connect(sock_file)
+        except socket.error as err:
+            sock.close()
+            return False
+        else:
+            sock.close()
+            return True
 
 
     def shutdown(self):
     def shutdown(self):
         self._write_sock.send(b"shutdown") #terminate the xfrout session thread
         self._write_sock.send(b"shutdown") #terminate the xfrout session thread