System-wide mutex in Python on Linux

后端 未结 6 1383
终归单人心
终归单人心 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:47

    For a system-wide mutex that enables the synchronization of absolutely separate processes (i.e., to INCLUDE Linux processes that do NOT belong to the same processes tree), simply use fcntl.flock. I suppose that using a memory file under Linux' /run/shm folder may make it perform faster.

    See more here.

提交回复
热议问题