System-wide mutex in Python on Linux

后端 未结 6 1387
终归单人心
终归单人心 2020-12-04 21:02

Is there any easy way to have a system-wide mutex in Python on Linux? By \"system-wide\", I mean the mutex will be used by a group of Python processes; this is in c

6条回答
  •  渐次进展
    2020-12-04 21:34

    Just to add a one to the list, there's the posix_ipc library, which has a Semaphore class.

    A Semaphore with a count of 1 can be used as a Mutex. To complete the threading trio, the SystemEvent library makes use of posix_ipc and provides an Event as well.

    I'd also note that this doesn't poll your hard drive either!

提交回复
热议问题