python background function
import threading
def my_inline_function(some_args):
# do some stuff
download_thread = threading.Thread(target=some_function, name="Downloader", args=some_args)
download_thread.start()
# continue doing stuff
python background function
import threading
def my_inline_function(some_args):
# do some stuff
download_thread = threading.Thread(target=some_function, name="Downloader", args=some_args)
download_thread.start()
# continue doing stuff
how to check any script is running in background linux using python
def check_process():
import subprocess
script_name = "test.py"
cmd='pgrep -f .*python.*{}'.format(script_name)
process = subprocess.Popen(cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
my_pid, err = process.communicate()
if len(my_pid.splitlines()) >0:
print("Script Running in background")
sys.exit(0);
check_process()
how to make a python file run in the background
#Cmd
C:..>cd DIRECTORY
C:..DIRECTORY>pythonw python.py
#Close in Task Manager
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us