Python code for Multi-threading and using message queues to transmit messages between tasks

import threading
import os
from queue import Queue

def task1(in_q):
#while True:
        print("Task 1 assigned to thread: {}".format(threading.current_thread().name))
        print("ID of process running task 1: {}".format(os.getpid()))

def task2(out_q):
#    while True:
        print("Task 2 assigned to thread: {}".format(threading.current_thread().name))
        print("ID of process running task 2: {}".format(os.getpid()))
        print('message sent to task 3: I am neelkanth reddy... sending message')
        out_q.put('I am neelkanth reddy... sending message')

def task3(in_q):
#    while True:
        print("Task 3 assigned to thread: {}".format(threading.current_thread().name))
        print("ID of process running task 3: {}".format(os.getpid()))
        h = in_q.get()
        print('message received from task 2: '  + h)
        in_q.task_done()

if __name__ == "__main__":
   # print ID of current process
   print("ID of process running main program: {}".format(os.getpid()))

   # print name of main thread
   print("Main thread name: {}".format(threading.main_thread().name))

   q = Queue()


   # creating threads
   t1 = threading.Thread(target=task1, args=(q,), name='t1')
   t2 = threading.Thread(target=task2, args=(q,), name='t2')
   t3 = threading.Thread(target=task3, args=(q,), name='t3')


   # starting threads
   t1.start()
   t2.start()
   t3.start()

# wait until all threads finish
   t1.join()
   t2.join()
   t3.join()