与开放交易的客户端连接发生意外的EOF

Pen*_*ngJ 6 postgresql python-2.7

我想使用线程连接postgresql但显示postgresql日志吗?

与开放交易的客户端连接上的意外EOF

这是我的代码?

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()
Run Code Online (Sandbox Code Playgroud)

dla*_*and 5

在某个时候,服务器接收到一个客户端连接,该客户端连接提供了适当的凭据(因此建立了会话)。

此日志消息通知您客户端断开了会话“会话刚走开!” 没有干净地关闭。也许代码在到达cur.close()语句之前引发了异常。