System-wide mutex in Python on Linux

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

    Try ilock library:

    from ilock import ILock
    
    with ILock('Unique lock name'):
        # The code should be run as a system-wide single instance
        ...
    

提交回复
热议问题