Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/env python
- # encoding: utf-8
- #
- # Copyright (c) 2008 Doug Hellmann All rights reserved.
- #
- """Daemon vs. non-daemon processes.
- """
- #end_pymotw_header
- import multiprocessing
- import time
- import sys
- def daemon():
- name = multiprocessing.current_process().name
- print 'Starting:', name
- time.sleep(2)
- print 'Exiting :', name
- def non_daemon():
- name = multiprocessing.current_process().name
- print 'Starting:', name
- print 'Exiting :', name
- if __name__ == '__main__':
- d = multiprocessing.Process(name='daemon',
- target=daemon)
- d.daemon = True
- n = multiprocessing.Process(name='non-daemon',
- target=non_daemon)
- n.daemon = False
- d.start()
- time.sleep(1)
- n.start()
- d.join()
- n.join()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement