开发者

strange error of the semaphore in python

开发者 https://www.devze.com 2023-03-31 04:45 出处:网络
Can somebody please explain to me why I am receiving an error in the following code? win32event.Wa开发者_如何学编程itForSingleObject(self.my_lock, win32event.INFINITE)

Can somebody please explain to me why I am receiving an error in the following code?

win32event.Wa开发者_如何学编程itForSingleObject(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_ABANDONED is 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 the WAIT_ABANDONED result from WaitFromSingleObject()).

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_ABANDONED error, read this MSDN article)

0

精彩评论

暂无评论...
验证码 换一张
取 消