How to avoid multiple instances of a program?

前端 未结 3 505
没有蜡笔的小新
没有蜡笔的小新 2021-01-02 11:19

I need to find a right way to prevent two running instances of my (Python) program. I am currently using the following method.

On Windows,

os.popen(\         


        
3条回答
  •  渐次进展
    2021-01-02 11:49

    There are numerous ways:

    1. have an "instance file" in /var/run or similar (cross-platform)
    2. use a fixed socket (cross-platform)
    3. use DBus to register a name (linux)

    What you need is a service (external to your application) that manages a namespace where unique ids are available & enforced.

提交回复
热议问题