annotate Lib/multiprocessing/process.py @ 58925:eecf1bef052d 2.6

Merged revisions 78207 via svnmerge from svn+ssh://pythondev@svn.python.org/python/trunk ........ r78207 | ezio.melotti | 2010-02-17 01:26:09 +0200 (Wed, 17 Feb 2010) | 1 line #7930: fix stripid ........
author Ezio Melotti <ezio.melotti@gmail.com>
date Tue, 16 Feb 2010 23:29:44 +0000
parents 427c2143e2c9
children 295d59fa6e62
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
1 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
2 # Module providing the `Process` class which emulates `threading.Thread`
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
3 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
4 # multiprocessing/process.py
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
5 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
6 # Copyright (c) 2006-2008, R Oudkerk --- see COPYING.txt
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
7 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
8
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
9 __all__ = ['Process', 'current_process', 'active_children']
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
10
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
11 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
12 # Imports
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
13 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
14
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
15 import os
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
16 import sys
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
17 import signal
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
18 import itertools
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
19
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
20 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
21 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
22 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
23
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
24 try:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
25 ORIGINAL_DIR = os.path.abspath(os.getcwd())
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
26 except OSError:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
27 ORIGINAL_DIR = None
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
28
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
29 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
30 # Public functions
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
31 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
32
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
33 def current_process():
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
34 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
35 Return process object representing the current process
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
36 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
37 return _current_process
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
38
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
39 def active_children():
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
40 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
41 Return list of process objects corresponding to live child processes
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
42 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
43 _cleanup()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
44 return list(_current_process._children)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
45
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
46 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
47 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
48 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
49
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
50 def _cleanup():
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
51 # check for processes which have finished
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
52 for p in list(_current_process._children):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
53 if p._popen.poll() is not None:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
54 _current_process._children.discard(p)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
55
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
56 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
57 # The `Process` class
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
58 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
59
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
60 class Process(object):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
61 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
62 Process objects represent activity that is run in a separate process
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
63
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
64 The class is analagous to `threading.Thread`
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
65 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
66 _Popen = None
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
67
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
68 def __init__(self, group=None, target=None, name=None, args=(), kwargs={}):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
69 assert group is None, 'group argument must be None for now'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
70 count = _current_process._counter.next()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
71 self._identity = _current_process._identity + (count,)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
72 self._authkey = _current_process._authkey
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
73 self._daemonic = _current_process._daemonic
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
74 self._tempdir = _current_process._tempdir
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
75 self._parent_pid = os.getpid()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
76 self._popen = None
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
77 self._target = target
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
78 self._args = tuple(args)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
79 self._kwargs = dict(kwargs)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
80 self._name = name or type(self).__name__ + '-' + \
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
81 ':'.join(str(i) for i in self._identity)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
82
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
83 def run(self):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
84 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
85 Method to be run in sub-process; can be overridden in sub-class
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
86 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
87 if self._target:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
88 self._target(*self._args, **self._kwargs)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
89
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
90 def start(self):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
91 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
92 Start child process
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
93 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
94 assert self._popen is None, 'cannot start a process twice'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
95 assert self._parent_pid == os.getpid(), \
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
96 'can only start a process object created by current process'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
97 assert not _current_process._daemonic, \
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
98 'daemonic processes are not allowed to have children'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
99 _cleanup()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
100 if self._Popen is not None:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
101 Popen = self._Popen
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
102 else:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
103 from .forking import Popen
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
104 self._popen = Popen(self)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
105 _current_process._children.add(self)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
106
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
107 def terminate(self):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
108 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
109 Terminate process; sends SIGTERM signal or uses TerminateProcess()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
110 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
111 self._popen.terminate()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
112
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
113 def join(self, timeout=None):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
114 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
115 Wait until child process terminates
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
116 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
117 assert self._parent_pid == os.getpid(), 'can only join a child process'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
118 assert self._popen is not None, 'can only join a started process'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
119 res = self._popen.wait(timeout)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
120 if res is not None:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
121 _current_process._children.discard(self)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
122
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
123 def is_alive(self):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
124 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
125 Return whether process is alive
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
126 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
127 if self is _current_process:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
128 return True
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
129 assert self._parent_pid == os.getpid(), 'can only test a child process'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
130 if self._popen is None:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
131 return False
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
132 self._popen.poll()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
133 return self._popen.returncode is None
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
134
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
135 @property
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
136 def name(self):
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
137 return self._name
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
138
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
139 @name.setter
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
140 def name(self, name):
57922
427c2143e2c9 Merged revisions 77038 via svnmerge from
Benjamin Peterson <benjamin@python.org>
parents: 55385
diff changeset
141 assert isinstance(name, basestring), 'name must be a string'
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
142 self._name = name
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
143
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
144 @property
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
145 def daemon(self):
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
146 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
147 Return whether process is a daemon
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
148 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
149 return self._daemonic
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
150
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
151 @daemon.setter
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
152 def daemon(self, daemonic):
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
153 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
154 Set whether process is a daemon
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
155 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
156 assert self._popen is None, 'process has already started'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
157 self._daemonic = daemonic
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
158
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
159 @property
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
160 def authkey(self):
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
161 return self._authkey
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
162
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
163 @authkey.setter
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
164 def authkey(self, authkey):
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
165 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
166 Set authorization key of process
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
167 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
168 self._authkey = AuthenticationString(authkey)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
169
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
170 @property
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
171 def exitcode(self):
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
172 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
173 Return exit code of process or `None` if it has yet to stop
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
174 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
175 if self._popen is None:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
176 return self._popen
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
177 return self._popen.poll()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
178
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
179 @property
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
180 def ident(self):
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
181 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
182 Return indentifier (PID) of process or `None` if it has yet to start
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
183 '''
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
184 if self is _current_process:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
185 return os.getpid()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
186 else:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
187 return self._popen and self._popen.pid
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
188
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
189 pid = ident
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
190
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
191 def __repr__(self):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
192 if self is _current_process:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
193 status = 'started'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
194 elif self._parent_pid != os.getpid():
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
195 status = 'unknown'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
196 elif self._popen is None:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
197 status = 'initial'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
198 else:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
199 if self._popen.poll() is not None:
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
200 status = self.exitcode
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
201 else:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
202 status = 'started'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
203
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
204 if type(status) is int:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
205 if status == 0:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
206 status = 'stopped'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
207 else:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
208 status = 'stopped[%s]' % _exitcode_to_name.get(status, status)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
209
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
210 return '<%s(%s, %s%s)>' % (type(self).__name__, self._name,
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
211 status, self._daemonic and ' daemon' or '')
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
212
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
213 ##
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
214
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
215 def _bootstrap(self):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
216 from . import util
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
217 global _current_process
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
218
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
219 try:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
220 self._children = set()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
221 self._counter = itertools.count(1)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
222 try:
55385
fda9062ebfa4 Merged revisions 73708,73738 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 48302
diff changeset
223 sys.stdin.close()
fda9062ebfa4 Merged revisions 73708,73738 via svnmerge from
R. David Murray <rdmurray@bitdance.com>
parents: 48302
diff changeset
224 sys.stdin = open(os.devnull)
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
225 except (OSError, ValueError):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
226 pass
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
227 _current_process = self
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
228 util._finalizer_registry.clear()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
229 util._run_after_forkers()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
230 util.info('child process calling self.run()')
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
231 try:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
232 self.run()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
233 exitcode = 0
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
234 finally:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
235 util._exit_function()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
236 except SystemExit, e:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
237 if not e.args:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
238 exitcode = 1
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
239 elif type(e.args[0]) is int:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
240 exitcode = e.args[0]
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
241 else:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
242 sys.stderr.write(e.args[0] + '\n')
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
243 sys.stderr.flush()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
244 exitcode = 1
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
245 except:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
246 exitcode = 1
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
247 import traceback
48302
7ea805d879e1 issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
Jesse Noller <jnoller@gmail.com>
parents: 47823
diff changeset
248 sys.stderr.write('Process %s:\n' % self.name)
47696
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
249 sys.stderr.flush()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
250 traceback.print_exc()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
251
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
252 util.info('process exiting with exitcode %d' % exitcode)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
253 return exitcode
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
254
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
255 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
256 # We subclass bytes to avoid accidental transmission of auth keys over network
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
257 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
258
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
259 class AuthenticationString(bytes):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
260 def __reduce__(self):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
261 from .forking import Popen
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
262 if not Popen.thread_is_spawning():
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
263 raise TypeError(
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
264 'Pickling an AuthenticationString object is '
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
265 'disallowed for security reasons'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
266 )
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
267 return AuthenticationString, (bytes(self),)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
268
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
269 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
270 # Create object representing the main process
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
271 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
272
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
273 class _MainProcess(Process):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
274
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
275 def __init__(self):
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
276 self._identity = ()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
277 self._daemonic = False
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
278 self._name = 'MainProcess'
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
279 self._parent_pid = None
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
280 self._popen = None
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
281 self._counter = itertools.count(1)
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
282 self._children = set()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
283 self._authkey = AuthenticationString(os.urandom(32))
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
284 self._tempdir = None
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
285
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
286 _current_process = _MainProcess()
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
287 del _MainProcess
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
288
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
289 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
290 # Give names to some return codes
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
291 #
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
292
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
293 _exitcode_to_name = {}
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
294
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
295 for name, signum in signal.__dict__.items():
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
296 if name[:3]=='SIG' and '_' not in name:
d01165fae98e darn! I converted half of the files the wrong way.
Benjamin Peterson <benjamin@python.org>
parents: 47694
diff changeset
297 _exitcode_to_name[-signum] = name