@@ -103,6 +103,12 @@ def _init_class(cls):
103103 cls ._dbiter_ref = cls ._dbiter ()
104104
105105 db_config = cls ._config ['db' ][0 ]
106+
107+ if 'query_timeout' not in db_config :
108+ db_config ['query_timeout' ] = 5000
109+ if 'session_tmp_buffer' not in db_config :
110+ db_config ['session_tmp_buffer' ] = 128
111+
106112 statement_timeout = 'statement_timeout={}' .format (db_config ['query_timeout' ])
107113 temp_buffers = 'temp_buffers={}MB' .format (db_config ['session_tmp_buffer' ])
108114
@@ -216,10 +222,12 @@ def get_connection_count(cls, connection):
216222 (group , group_id ) = connection
217223 cls .logger .debug ('connection get_connection_count() group_id:{}' .format (group_id ))
218224 connections = cls ._config ['groups' ][group ]['connections' ]
225+
219226 for (conn_ref , status ) in connections :
220227 cls .logger .debug ('connection get_connection_count() conn_ref:{} status:{}' .format (conn_ref , status ))
221228 if status == 'occupied' :
222229 connection_count += 1
230+
223231 return connection_count
224232
225233 @classmethod
@@ -236,6 +244,7 @@ def set_connection_status(cls, connection, status):
236244 connection_by_id = connections [group_id ]
237245 new_connection = (connection_by_id [0 ], status )
238246 connections [group_id ] = new_connection
247+
239248 cls .logger .debug ('connection set_connection_status() group_id:{} status:{} con_ref:{}' .format (
240249 group_id ,
241250 status ,
@@ -271,6 +280,11 @@ def connect(cls, connection):
271280
272281 cls .logger .debug ('connection connect() db_config:{}' .format (db_container ))
273282
283+ if 'ssl' not in db_container :
284+ db_container ['ssl' ] = 'disable'
285+ if 'connect_timeout' not in db_container :
286+ db_container ['connect_timeout' ] = 10
287+
274288 group_container ['connections' ][conn_id ] = (
275289 psycopg2 .connect (
276290 dbname = db_container ['name' ],
@@ -316,7 +330,7 @@ def reconnect(cls, connection):
316330 return
317331 except DBConnectionError as e :
318332 cls .logger .debug ('connection reconnect() exception:{}' .format (repr (e )))
319- time .sleep (cls . _config [ 'db' ][ 'connection_retry_sleep' ] )
333+ time .sleep (1 )
320334
321335
322336class Query (object ):
0 commit comments