Browse Source

[1828] Remove another use of with statement on sockets

This is because CPython < version 3.2 does not support it.
Mukund Sivaraman 13 years ago
parent
commit
60e8cc24f3
1 changed files with 3 additions and 2 deletions
  1. 3 2
      src/bin/xfrout/xfrout.py.in

+ 3 - 2
src/bin/xfrout/xfrout.py.in

@@ -753,8 +753,9 @@ class UnixSockServer(socketserver_mixin.NoPollMixIn,
             # (Any idea how to simulate this in test?)
             sock_domain = socket.AF_INET
 
-        with socket.fromfd(sock_fd, sock_domain, socket.SOCK_STREAM) as sock:
-            peer = sock.getpeername()
+        sock = socket.fromfd(sock_fd, sock_domain, socket.SOCK_STREAM)
+        peer = sock.getpeername()
+        sock.close()
 
         # Identify the correct socket family.  Due to the above "trick",
         # we cannot simply use sock.family.