Here is my workaround:
In the database, I create a table called RunningStatus with only one field, status , which is bit , and only one row, initially set to 0.
At the beginning of my stored procedure, I execute the line
update RunningStatus set status = 1;
And at the end of the stored procedure
update RunningStatus set status = 0;
In my Python script, I open a new connection and cursor to the same database. After my execute line, I just add
while 1: q = status_check_cursor.execute('select status from RunningStatus').fetchone() if q[0] == 0: break
You need to create a new connection and cursor, because any calls from the old connection will interrupt the stored procedure and could potentially cause status never return to 0.
It's a bit janky, but it works great for me!
Ben caine
source share