Search
 
SCRIPT & CODE EXAMPLE
 

PYTHON

python catch sigterm

#!/usr/bin/python

from time import sleep
import signal
import sys


def sigterm_handler(_signo, _stack_frame):
    # Raises SystemExit(0):
    sys.exit(0)

if sys.argv[1] == "handle_signal":
    signal.signal(signal.SIGTERM, sigterm_handler)

try:
    print "Hello"
    i = 0
    while True:
        i += 1
        print "Iteration #%i" % i
        sleep(1)
finally:
    print "Goodbye"
Comment

PREVIOUS NEXT
Code Example
Python :: Python how to use __gt__ 
Python :: dataframe rename column 
Python :: python initialise dataframe 
Python :: icon tkiner 
Python :: how to print on python 
Python :: np.array average row 
Python :: sort list in python by substring 
Python :: how to write multi line lambda in python 
Python :: python execute time 
Python :: colab install library 
Python :: pandas list to df 
Python :: how to veiw and edit files with python 
Python :: pandas append index ignore 
Python :: install lz4 python 3 
Python :: py how to deactivate venv 
Python :: dice rolling simulator python 
Python :: how to find if user input is lower case or upper case in python 
Python :: numpy array equal 
Python :: parquet to dataframe 
Python :: python datetime no milliseconds 
Python :: login_required 
Python :: jupyter lab 
Python :: python pandas remove non-numeric characters from multiple columns 
Python :: string startswith python 
Python :: pandas remove column 
Python :: minimum of two columns in pandas 
Python :: how to write a file in python 
Python :: Adding new column to existing DataFrame in Pandas by assigning a list 
Python :: python datetime get all days between two dates 
Python :: how to pair up two lists in python 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =