import time
import logging
import multiprocessing
def sleep_5_seconds():
logging.info(' Will sleep 5 seconds')
time.sleep(5)
logging.info(' Done sleeping 5 seconds')
def sleep_10_seconds():
logging.info(' Will sleep 10 seconds')
time.sleep(10)
logging.info(' Done sleeping 10 seconds')
def main():
logging.basicConfig(level = logging.INFO)
PROCESS1 = multiprocessing.Process(target = sleep_5_seconds)
PROCESS2 = multiprocessing.Process(target = sleep_10_seconds)
PROCESS1.start()
PROCESS2.start()
main()OUTPUT:
INFO:root: Will sleep 5 seconds
INFO:root: Will sleep 10 seconds
After 5 seconds
INFO:root: Done sleeping 5 seconds
After another 5 seconds
INFO:root: Done sleeping 10 seconds

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store