[cx-oracle-users] how to cancel connecting to database which is down?
Brought to you by:
atuining
From: Michał N. <mm...@gm...> - 2013-11-06 18:42:54
|
Hello, Please take a look at this simple code: import cx_Oracle as db dsn = '(DESCRIPTION =(CONNECT_TIMEOUT=3)(RETRY_COUNT=1)(TRANSPORT_CONNECT_TIMEOUT=3)(ADDRESS_LIST =(ADDRESS = (PROTOCOL = TCP)(HOST = SOME_HOST)(PORT = 1531)))(CONNECT_DATA =(SERVICE_NAME = SOME_NAME)))' connect_string = "LOGIN/PASSWORD@%s" % dsn conn = db.connect(connect_string) conn.ping() # WILL HANG FOREVER!!! If `SOME_HOST` is down, this will hang forever! And it's not related to `OCIPing` - if I replace: ping() with: cursor = conn.cursor() cursor.execute('SELECT 1 FROM DUAL') # HANG FOREVER AS WELL This will hang as well. I'm using **SQL*Plus: Release 11.2.0.3.0 Production on Wed Nov 6 12:17:09 2013**. I tried wrapping this code in thread and waiting for same time than killing the thread but this doesn't work. This code creates a thread itself and it's impossible from python to kill it. Do you have any ideas how to recover? Kind regards, Michał Nowotka |