Unexpected Eof on Client Connection with an Open Transaction
I Want to Using Threading to Connect Postgresql but Postgresql Log Show: Unexpected Eof on Client Connection with an Open Transaction Here Is My Code: Conn =...
I want to using threading to connect postgresql but postgresql log show:
unexpected EOF on client connection with an open transaction
here is my code:
conn = []
for i in range(10):
conn.append(psycopg2.connect("dbname=test user=higis password=dbrgdbrg host=10.1.1.215 port=5432"))
print conn
def test_query(a,b,c,d,name,i):
try:
#conn = psycopg2.connect("dbname=test user=higis password=dbrgdbrg host=10.1.1.215 port=5432")
cur = conn[i].cursor()
sql_query = "SELECT count(*) FROM " + str(name) + " WHERE ST_MAKEENVELOPE" + str(
(a, b, c, d, 4326)) + "&& wkb_geometry"
start = time.time()
cur.execute(sql_query)
#conn.commit()
end = time.time()
results_time = end - start
results = cur.fetchall()
cur.close()
conn[i].close()
#print results
#print results[0][0]
suit_f = open("/home/pj/Desktop/test/log/replicate_query_time.txt", 'a')
print >> suit_f, (
'range query table:,%s,(%s %s %s %s),%s,%s' % (name, a, b, c, d, results[0][0], results_time))
except Exception, e:
print e
a_all = [1,2,3,4,5,6,7,8,9,10]
b_all = [1,2,3,4,5,6,7,8,9,10]
c_all = [1,2,3,4,5,6,7,8,9,10]
d_all = [1,2,3,4,5,6,7,8,9,10]
threads = []
for i in range(10):
a = a_all[i]
b = b_all[i]
c = c_all[i]
d = d_all[i]
t = threading.Thread(target=test_query,args=(a,b,c,d,"replicate_table1",i))
threads.append(t)
if __name__ == '__main__':
i = 0
for t in threads:
print "Thread:" + str(i) + " t and the time = %s" %(ctime())
t.setDaemon(True)
t.start()
i = i+1
t.join()
#conn.commit()
1 Answer
At some point the server received a client connection which presented the appropriate credentials (and thus a session was established).
This log message is informing you that the client disconnected the session "it just walked away!" without shutting down cleanly. Maybe the code is throwing an exception before it gets to the cur.close() statement.