Changeset 1856
- Timestamp:
- 02/11/08 13:49:09 (2 months ago)
- svm:headrev:
cc3e1ea1-1e01-0410-8d68-8b121e83a9d5:11138- Files:
-
- 1 modified
-
freevo/src/childapp.py (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
freevo/src/childapp.py
r1748 r1856 85 85 86 86 command = ('%s %s' % (config.RUNAPP, app)).strip() 87 debug_name = app[:app.find(' ')]87 app_name = app[:app.find(' ')] 88 88 89 89 else: … … 104 104 command = app 105 105 106 debug_name = app[0]107 108 if debug_name.rfind('/') > 0:109 debug_name = debug_name[debug_name.rfind('/')+1:]106 app_name = app[0] 107 108 if app_name.rfind('/') > 0: 109 app_name = app_name[app_name.rfind('/')+1:] 110 110 else: 111 debug_name = debug_name111 app_name = app_name 112 112 113 113 if debugname: 114 debug_name = debugname114 app_name = debugname 115 115 116 116 if doeslogging or config.DEBUG_CHILDAPP: 117 117 doeslogging = 1 118 119 if doeslogging:120 stdout_logger = os.path.join(config.FREEVO_LOGDIR, '%s-stdout-%s.log' % (debug_name, os.getuid()))121 try:122 self.stdout_log = open(stdout_logger, 'w')123 except OSError, why:124 _debug_('Cannot open "%s": %s' % (stdout_logger, why), DWARNING)125 self.stdout_log = None126 127 stderr_logger = os.path.join(config.FREEVO_LOGDIR, '%s-stderr-%s.log' % (debug_name, os.getuid()))128 try:129 self.stderr_log = open(stderr_logger, 'w')130 except OSError, why:131 _debug_('Cannot open "%s": %s' % (stderr_logger, why), DWARNING)132 self.stderr_log = None133 else:134 self.stdout_log = None135 self.stderr_log = None136 118 137 119 command_isstr = isinstance(command, str) … … 157 139 return 158 140 159 self.so = Read_Thread('stdout', self.child.stdout, self.stdout_cb, debug_name, doeslogging, callback_use_rc)141 self.so = Read_Thread('stdout', self.child.stdout, self.stdout_cb, app_name, doeslogging, callback_use_rc) 160 142 self.so.setDaemon(1) 161 143 self.so.start() 162 144 163 self.se = Read_Thread('stderr', self.child.stderr, self.stderr_cb, debug_name, doeslogging, callback_use_rc)145 self.se = Read_Thread('stderr', self.child.stderr, self.stderr_cb, app_name, doeslogging, callback_use_rc) 164 146 self.se.setDaemon(1) 165 147 self.se.start() … … 238 220 _debug_('killed %s the easy way, status %s' % (self.child.pid, self.status)) 239 221 if not self.child.stdin.closed: self.child.stdin.close() 240 if self.stdout_log: self.stdout_log.close()241 if self.stderr_log: self.stderr_log.close()242 222 self.child = None 243 223 return … … 301 281 self.lock.release() 302 282 if not self.child.stdin.closed: self.child.stdin.close() 303 if self.stdout_log: self.stdout_log.close()304 if self.stderr_log: self.stderr_log.close()305 283 self.child = None 306 284 … … 391 369 Thread for reading stdout or stderr from the child 392 370 """ 393 def __init__(self, name, fh, callback, logger=None, doeslogging=0, callback_use_rc=True):371 def __init__(self, name, fh, callback, appname=None, doeslogging=0, callback_use_rc=True): 394 372 """ 395 373 Constructor of Read_Thread 396 374 """ 397 _debug_('Read_Thread.__init__(name=%r, fh=%r, callback=%r, logger=%r, doeslogging=%r' % \398 (name, fh, callback, logger, doeslogging), 2)375 _debug_('Read_Thread.__init__(name=%r, fh=%r, callback=%r, appname=%r, doeslogging=%r, callback_use_rc=%r)' % \ 376 (name, fh, callback, appname, doeslogging, callback_use_rc), 2) 399 377 threading.Thread.__init__(self) 400 378 self.name = name … … 403 381 self.callback_use_rc = callback_use_rc 404 382 self.logger = None 405 if logger and doeslogging: 406 logfile = os.path.join(config.FREEVO_LOGDIR, '%s-%s-%s.log' % (logger, name, os.getuid())) 383 if appname and doeslogging: 384 t = time.strftime('%s') 385 logfile = os.path.join(config.FREEVO_LOGDIR, '%s-%s-%s-%s.log' % (appname, name, os.getuid(), t)) 407 386 try: 408 387 try:
