R
R
Ridalit2020-05-31 20:13:49
Python
Ridalit, 2020-05-31 20:13:49

How to get a list of running processes without using psutil?

I have a script:

for proc in psutil.process_iter(): 
    if proc.name() == "print.exe": 
        exit(0)

It uses psutil and prevents my program from running 2 times, which is quite critical for it.
Everything works fine until it is compiled into an .exe via pyinstaller, after that the program does not start, and by the exception method, I found out that this is the point of the code sections.

Is there a way to implement the same script using a different module, or fix the error using psutil?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
G
galaxy, 2020-05-31
@galaxy

Not the best way to prevent restart.
The program can, for example, open a certain file in exclusive mode. The second instance should try to open it and exit if it is blocked.

R
Rais, 2020-05-31
@0pauc0

https://ru.stackoverflow.com/questions/815923/Ne-z...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question