Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
autophone_queue, queue, loglevel, mailer):
self.state = ProcessStates.RUNNING
self.parent_worker = parent_worker
self.tests = tests
self.dm = dm
self.phone = phone
self.options = options
# Grab the main process logger for this worker that was set up
# in the PhoneWorker class. All logging for the
# PhoneWorkerSubProcess which occurs on the main autophone
# process will use this logger. Logging from the
# PhoneWorkerSubprocess' child process will use a distinct
# logger.
logger = utils.getLogger(name=phone.id)
self.loggerdeco = LogDecorator(logger,
{},
'PhoneWorkerSubProcess %(message)s')
# PhoneWorkerSubProcess.autophone_queue is used to pass
# messages back to the main Autophone process while
# PhoneWorkerSubProcess.queue is used to get messages from the
# main process.
self.autophone_queue = autophone_queue
self.queue = parent_worker.queue
self.outfile = '%s-%s.out' % (os.path.splitext(options.logfile)[0], phone.id)
self.test_logfile = None
self.loglevel = loglevel
self.mailer = mailer
self.p = None
self.jobs = None
self.build = None
self.last_ping = None
def clone(self, extradict=None, extraformat=None):
extradict = extradict or self._extradict
extraformat = extraformat or self._extraformat
return LogDecorator(self._logger, extradict, extraformat)
self.state = ProcessStates.STARTING
self.tests = tests
self.dm = dm
self.phone = phone
self.options = options
self.last_status_msg = None
self.first_status_of_type = None
self.last_status_of_previous_type = None
# The PhoneWorker logger operates in the main autophone process
# and will propagate to the autophone logger.
self.logger = utils.getLogger(name=phone.id)
self.logger.setLevel(loglevel)
self.loglevel = loglevel
self.loggerdeco = LogDecorator(self.logger,
{},
'PhoneWorker %(message)s')
self.loggerdeco.debug('PhoneWorker:__init__')
self.crashes = Crashes(crash_window=options.phone_crash_window,
crash_limit=options.phone_crash_limit)
# Messages are passed to the PhoneWorkerSubProcess worker from
# the main process by PhoneWorker which puts messages into
# PhoneWorker.queue. PhoneWorkerSubProcess is given a
# reference to this queue and gets messages from the main
# process via this queue.
self.queue = multiprocessing.Queue()
self.lock = multiprocessing.Lock()
self.subprocess = PhoneWorkerSubProcess(dm,
self,
tests,
phone,
handler.flush()
handler.close()
root_logger.removeHandler(handler)
root_logger.addHandler(socket_handler)
self.logger = utils.getLogger()
self.logger.setLevel(self.loglevel)
self.logfile = '%s-%s.log' % (os.path.splitext(self.options.logfile)[0], self.phone.id)
# Open the logfile for appending. If necessary we will delete
# the log after submitting to Treeherder.
self.filehandler = logging.FileHandler(self.logfile, mode='a')
self.fileformatter = logging.Formatter(utils.getLoggerFormatString(self.loglevel))
self.filehandler.setFormatter(self.fileformatter)
self.logger.addHandler(self.filehandler)
self.loggerdeco = LogDecorator(self.logger,
{},
'%(message)s')
# Create a special formatter to be used solely for Treeherder
# step markers whose format does not use any leading
# information.
self.stepformatter = logging.Formatter('%(message)s')
self.log_step('Starting Worker Process')
self.logcat = Logcat(self)
self.loggerdeco.info('Worker: Connecting to %s...', self.phone.id)
# Override mozlog.logger
self.dm._logger = self.loggerdeco
self.jobs = jobs.Jobs(self.mailer,