Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import multiprocessing
- def worker():
- """ Worker function """
- p = multiprocessing.current_process()
- print("name:", p.name, " starting", p.pid)
- print("name:", p.name, " exiting", p.pid)
- return
- def service():
- p = multiprocessing.current_process()
- print("name:", p.name, " starting", p.pid)
- print("name:", p.name, " exiting", p.pid)
- return
- if __name__ == '__main__':
- count_service = 0
- count_worker = 0
- for x in range(10):
- p = multiprocessing.Process(name='worker',target=worker)
- p.daemon = True
- p.start()
- xservice = multiprocessing.Process(name='service', target=service)
- xservice.start()
- count = 0
- if p.is_alive():
- print('daemon is alive')
Advertisement
Add Comment
Please, Sign In to add comment