Message93976
`self.processName` could be a lazily computed property, since it doesn't
seem to be used anywhere by default. Something like:
_processName = None
@property
def processName(self):
n = self._processName
if n is not None:
return n
if 'multiprocessing' not in sys.modules:
n = 'mainProcess'
else:
n = sys.modules['multiprocessing'].current_process().name
self._processName = n
return n
If you don't like the overhead of a property, you could do the caching
dance in a __getattr__ method instead.
NB : if 'multiprocessing' isn't in sys.modules, it means that you can
only be in the main process, as far as I understand. Processes launched
by multiprocessing itself *will* have 'multiprocessing' in sys.modules,
unless it is doing really weird stuff. |
|
Date |
User |
Action |
Args |
2009-10-14 12:00:51 | pitrou | set | recipients:
+ pitrou, gvanrossum, vinay.sajip, amaury.forgeotdarc, pjenvey, benjamin.peterson |
2009-10-14 12:00:51 | pitrou | set | messageid: <1255521651.79.0.229494206922.issue7120@psf.upfronthosting.co.za> |
2009-10-14 12:00:47 | pitrou | link | issue7120 messages |
2009-10-14 12:00:47 | pitrou | create | |
|