diff options
author | Benjamin Peterson <benjamin@python.org> | 2008-08-19 19:17:39 (GMT) |
---|---|---|
committer | Benjamin Peterson <benjamin@python.org> | 2008-08-19 19:17:39 (GMT) |
commit | 58ea9fedc825a91a3b153898afade19512bbde85 (patch) | |
tree | 97f626c59079f769595e8382f330511378beb168 /Lib/multiprocessing/process.py | |
parent | be2c2b23137e93f163c87fb27c65593516f153c2 (diff) | |
download | cpython-58ea9fedc825a91a3b153898afade19512bbde85.zip cpython-58ea9fedc825a91a3b153898afade19512bbde85.tar.gz cpython-58ea9fedc825a91a3b153898afade19512bbde85.tar.bz2 |
Merged revisions 65864 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk
........
r65864 | jesse.noller | 2008-08-19 14:06:19 -0500 (Tue, 19 Aug 2008) | 2 lines
issue3352: clean up the multiprocessing API to remove many get_/set_ methods and convert them to properties. Update the docs and the examples included.
........
Diffstat (limited to 'Lib/multiprocessing/process.py')
-rw-r--r-- | Lib/multiprocessing/process.py | 39 |
1 files changed, 19 insertions, 20 deletions
diff --git a/Lib/multiprocessing/process.py b/Lib/multiprocessing/process.py index 1f89dba..e21d2f0 100644 --- a/Lib/multiprocessing/process.py +++ b/Lib/multiprocessing/process.py @@ -132,45 +132,43 @@ class Process(object): self._popen.poll() return self._popen.returncode is None - def get_name(self): - ''' - Return name of process - ''' + @property + def name(self): return self._name - def set_name(self, name): - ''' - Set name of process - ''' + @name.setter + def name(self, name): assert isinstance(name, str), 'name must be a string' self._name = name - def is_daemon(self): + @property + def daemon(self): ''' Return whether process is a daemon ''' return self._daemonic - def set_daemon(self, daemonic): + @daemon.setter + def daemon(self, daemonic): ''' Set whether process is a daemon ''' assert self._popen is None, 'process has already started' self._daemonic = daemonic - def get_authkey(self): - ''' - Return authorization key of process - ''' + @property + def authkey(self): return self._authkey - def set_authkey(self, authkey): + @authkey.setter + def authkey(self, authkey): ''' Set authorization key of process ''' self._authkey = AuthenticationString(authkey) - def get_exitcode(self): + @property + def exitcode(self): ''' Return exit code of process or `None` if it has yet to stop ''' @@ -178,7 +176,8 @@ class Process(object): return self._popen return self._popen.poll() - def get_ident(self): + @property + def ident(self): ''' Return indentifier (PID) of process or `None` if it has yet to start ''' @@ -187,7 +186,7 @@ class Process(object): else: return self._popen and self._popen.pid - pid = property(get_ident) + pid = ident def __repr__(self): if self is _current_process: @@ -198,7 +197,7 @@ class Process(object): status = 'initial' else: if self._popen.poll() is not None: - status = self.get_exitcode() + status = self.exitcode else: status = 'started' @@ -245,7 +244,7 @@ class Process(object): except: exitcode = 1 import traceback - sys.stderr.write('Process %s:\n' % self.get_name()) + sys.stderr.write('Process %s:\n' % self.name) sys.stderr.flush() traceback.print_exc() |