Can somebody please explain to me why I am receiving an error in the following code?
win32event.WaitForSingleObject(self.my_lock, win32event.INFINITE)
win32event.ReleaseSemaphore(self.big_semaphore, 1)
win32event.ReleaseSemaphore(self.small_semaphore, 1)
win32event.ReleaseMutex(self.my_lock)
The strange thing here that if I comment one of the semaphores, like this:
#win32event.ReleaseSemaphore(self.big_semaphore, 1)
win32event.ReleaseSemaphore(self.small_semaphore, 1)
my code is running perfect, any idea? I can’t post the error log because it is very big and doesn’t relate to this part of my code.
More context:
I have a few processes which execute this piece of the code. The error I receive is that the mutex was WAIT_ABANDONED, but when I comment one of the calls to ReleaseSemaphore the code is running perfect.
WAIT_ABANDONEDis not really an error. It means that another thread or process was owning the mutex and terminated without releasing the mutex. The operating system grants ownership of the mutex to the next waiting thread (the one which receives theWAIT_ABANDONEDresult fromWaitFromSingleObject()).When receiving this result code, you can proceed as if you received a
WAIT_OBJECT_0, but beware of the state of the resources protected by the mutex.Anyway, you have to investigate this return code and try to find who is abandoning the mutex.
(For a little more explanation about the
WAIT_ABANDONEDerror, read this MSDN article)