process

How to run several python scripts in one file concurrently?

How to run several python scripts in one file concurrently? Question: I want to run several python scripts from the main file and make them work in parallel. I would like to print their outputs in a console if it is possible. It’s better to run them in different processes to be able to operate …

Total answers: 1

Gracefully handling keyboard interrupt for Python multi-processing

Gracefully handling keyboard interrupt for Python multi-processing Question: I am working on a project which runs two separate python processes. When I do a ctrl + c to end the program, I would like the program to end gracefully. I can produce a minimum working version of the code through the following: from multiprocessing import …

Total answers: 1

error using pipes in python using os.pipe() and using os.fork()

error using pipes in python using os.pipe() and using os.fork() Question: So I made a simple piece of code to add 1 to a value. I create two process and I am creating a pipe for storage the information beetween iterations. In the first cycle it gives the correct value but in the second iterration …

Total answers: 2

Check certain Popen is running at first (==Checking variable is assigned)

Check certain Popen is running at first (==Checking variable is assigned) Question: I got a running Thread p in a function and trying to check at first, whether it’s already running or not if p wasn’t running it spits reference before the assignment error from subprocess import check_output,Popen from asyncio.subprocess import PIPE from threading import …

Total answers: 1

Python starting processes with separate Thread leads to exception and death of that thread

Python starting processes with separate Thread leads to exception and death of that thread Question: I have my main function run_tests which firstly starts new, separate Thread that starts new processes and then in main loop I try to detect those that have finished and those that have timeouted. import time import traceback from typing …

Total answers: 1

Check files modification from a process with Python watchdog

Check files modification from a process with Python watchdog Question: I’m trying to use Python watchdog and I don’t know if it’s possible to check if a process modified/created/deleted files, can anyone help me? import sys import time import logging from watchdog.observers import Observer from watchdog.events import LoggingEventHandler logging.basicConfig(level=logging.INFO, format=’ %(message)s’) path = sys.argv[1] if …

Total answers: 1

How to get the process ID of python programm?

How to get the process ID of python programm? Question: Is there a way to get the process ID (PID) of a python program? The program was started from the command line. Asked By: asdewkas || Source Answers: this should do it: import os pid = os.getpid() print(pid) Answered By: Helmut

Total answers: 1

Python script for 'ps aux' command

Python script for 'ps aux' command Question: I have tried to use subprocess.check_output() for getting the ps aux command using python but it looks like not working with the large grep string. Can anyone have any solution? subprocess.check_output(‘ps aux | grep "bin/scrapy" | grep "option1" | grep "option2" | grep "option3" | grep "option4" | …

Total answers: 2