Blocked thread

Larry Martell larry.martell at gmail.com
Thu Jul 17 12:26:48 EDT 2014


I have a python cx_Oracle script that does a delete from a table.
Usually this takes well under 1 second. But sometimes it takes 1 to 2
minutes. I wanted to monitor that delete and if it's taking too long I
want to see what is blocking it. I run the delete sql in a thread and
I do this:


while self.isAlive():
  self.join(5)
  if self.isAlive():
     # run query to see who is blocking


Looking at the timing on this, at 13:45:11.780 I called join and at
13:46:20.118 I was running the query to check for blocking. That query
does not show that the delete is running and the next time through the
loop isAlive() is False. My WAG is that when the delete query is
blocked the join does not return and I am 'blocked' in the join() -
does that seem like what would happen? It's not what I would expect.
Can anyone think of a better way to do this? I could have a second
script that does it, but that's kinda messy.



More information about the Python-list mailing list