I wrote a python program (with SQL queries) that generally runs fine, but every once in a while it will hang until I click into the command line and press Enter. I usually run it in Anaconda prompt, but I have also used PyInstaller to wrap it in an executable and the problem persists. The problem also persists if I don't click away from the program.
I have print statements throughout the program and it does not necessarily stop at a specific spot, but it does always seem to happen during/after an SQL query. I'm using an Oracle db and importing cx_Oracle to read from it. There are no returned errors, it just gets stuck. This is a very inconsistent issue: running it the exact same way with the same values won't necessarily replicate the issue.
I know this is a somewhat generic problem, but I feel like there is no low-hanging fruit to try because of how inconsistent this issue is. Any troubleshooting advice would be helpful.
This is how I'm reading from the database: (server info is omitted)
def readFromServer(command):
CONN_INFO = { 'host': 'HOST', 'port': PORT, 'user': 'USER', 'psw': 'PSW', 'service': 'SERVICE', }
CONN_STR = '{user}/{psw}@{host}:{port}/{service}'.format(**CONN_INFO)
connection = cx_Oracle.connect(CONN_STR)
cursor = connection.cursor()
cursor.execute(command)
commandData = []
for i in cursor:
commandData.append(i)
return commandData
I did not include the full code because it is too long/IP issues. I can't show the sql command string, but given that it is just a slightly modified version of one that definitely works, I'm pretty sure that's not the problem. Essentially what my script does is reading user input from the gui, pulling the applicable data from an oracle server, simple data processing, then displaying the results in a gui.
I found multiple posts like this one that seems to have similar issues, but they generally revolve around powershell or command line input and those issues seem to consistently occur.