Fixes.
authorRadek Brich <radek.brich@devl.cz>
Wed, 23 May 2012 16:02:53 +0200
changeset 37 5b0eb4b11940
parent 36 e67101c22e83
child 38 d3593869d624
Fixes.
pgtoolkit/pgmanager.py
tests/config.py
tests/testpgmanager.py
--- a/pgtoolkit/pgmanager.py	Wed May 23 11:11:16 2012 +0200
+++ b/pgtoolkit/pgmanager.py	Wed May 23 16:02:53 2012 +0200
@@ -182,7 +182,7 @@
 
     def keep_alive(self):
         '''Set socket to keepalive mode. Must be called before any query.'''
-        sock = socket.fromfd(self.fileno(), socket.AF_INET, socket.SOCK_STREAM) 
+        sock = socket.fromfd(self.fileno(), socket.AF_INET, socket.SOCK_STREAM)
         sock.setsockopt(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)
         try:
             # Maximum keep-alive probes before asuming the connection is lost
@@ -193,6 +193,8 @@
             sock.setsockopt(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, 10)
         except socket.error:
             pass
+        # close duplicated fd, options set for socket stays
+        sock.close()
 
 
 class PgManager:
--- a/tests/config.py	Wed May 23 11:11:16 2012 +0200
+++ b/tests/config.py	Wed May 23 16:02:53 2012 +0200
@@ -5,6 +5,7 @@
 
 class Config(dict):
     def __init__(self, fname):
-        data = open(fname).read()
+        with open(fname) as f:
+            data = f.read()
         exec(data, dict(), self)
 
--- a/tests/testpgmanager.py	Wed May 23 11:11:16 2012 +0200
+++ b/tests/testpgmanager.py	Wed May 23 16:02:53 2012 +0200
@@ -1,4 +1,4 @@
-#!/usr/bin/env python
+#!/usr/bin/env python3.2
 
 import unittest