I am running a Python script (version 3.6.8) on AWS t2.micro instance with Amazon Linux AMI 2018.03. The script runs two long-running threads as shown below.
I monitor CPU and memory usage with htop, which shows 2 processes for my script both taking resources. Based on the output it doesn't seem like two processes are actually running. On macOS, where I developed the script, htop shows only 1 process for my script. The first image below shows collapsed processes on Linux and the second one shows them in a tree view.
Am I using Python threads the wrong way? Or do macOS and Linux show processes for python script differently?
from threading import Thread
from time import sleep
def thread(sec_sleep):
while 1:
print('sleep', sec_sleep)
sleep(sec_sleep)
def init_services():
t = Thread(target=thread, args=(1, ))
t.daemon = True
t.start()
def main():
init_services()
thread(2)
if __name__ == "__main__":
main()

