Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
# Copyright (c) 2014, Facebook, Inc. All rights reserved. # # This source code is licensed under the BSD-style license found in the # LICENSE file in the root directory of this source tree. An additional grant # of patent rights can be found in the PATENTS file in the same directory. #
return self.service.name
return str(self.service.VERSION)
# TODO: DEAD? STARTING? STOPPED? return fb_status.STOPPING # Only check LOOPLESS tasks for "dead" threads return fb_status.WARNING
# Return WARNING if there are any registered warnings return fb_status.WARNING
messages = [] if self.service._stop: messages.append('%s is shutting down' % (self.getName()))
# Check for dead threads for task in self.service.tasks: if not task.LOOPLESS: for thread in task.threads: if not thread.isAlive(): messages.append('%s has dead threads!' % task.name)
# Append any registered warnings messages.extend(self.service.getWarnings().values()) return '\n'.join(messages)
result = {} for k, v in iteritems(self.service.getCounters()): v = v() if v is None: continue result[k] = int(v) return result
result = self.service.getCounter(name)() if result is None: raise ValueError("%s is None" % (name)) return int(result)
if value == '__None__': value = None else: cur_value = getattr(self.service.options, name) if cur_value is not None: try: value = cur_value.__class__(value) except Exception as e: self.logger.debug('Unable to cast %s to %s (%s)', value, cur_value.__class__, e) self.service.setOption(name, value)
value = self.service.getOption(name) if value is None: value = '__None__' return str(value)
result = {} for k in self.service.getOptions(): result[k] = self.getOption(k) return result
return self.service.start_time
self.service.restart()
self.service.shutdown()
try: import yappi except ImportError: # Fallback (but log) if people call this method and we # don't have yappi self.logger.warning('getCpuProfile called without yappi installed') return ''
# We need to lock this since it muck about with the global python # profile hooks. with self._profile_lock: yappi.start() time.sleep(profileDurationInSec) yappi.stop() stats = yappi.get_func_stats()
# Save the "pretty" output to a buffer and return the raw string # Alternatively, we should return this as JSON and let the caller # render it appropriately, but this is fine for now. sio = StringIO() stats.print_all(out=sio) return sio.getvalue() |