How to access windows mutex in python?

Viewed 543

I have a program P1 (it was written in C# but that is essentially unimportant) that acquires a Win32 mutex. A second program P2 that I need to write in python uses a shared resource with P1. Since this resource is already protected by the Win32 mutex I just need to access the same mutex from python P2. My questions now are:

  1. I have not found any method to access existing windows mutex from the python multiprocessing package. Is there a way to do that?
  2. Alternatively, it could be possible to use the win32event package. But since there is only a very limited documentation with virtually no example code available, I am hesitant to further go in that direction. Do you know of any other resources on pywin32?
  3. It would be nice not to introduce new dependencies. How ever, if there is no other way, do you have suggestions for (well maintained) python packages?

I am just baffled that I could not find other people with similar questions. This should be a fairly common problem, right?

Edit: My question is different from this question. As explained in the accepted answer, the multiprocessing.Lock method is only able to lock python processes. I however, need to aquire an existing Windows mutex.

0 Answers
Related