You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
766 B

4 years ago
  1. from logging import INFO, DEBUG, WARN, ERROR, FATAL
  2. from zmq.log.handlers import PUBHandler
  3. import warnings
  4. warnings.warn("ipykernel.log is deprecated. It has moved to ipyparallel.engine.log", DeprecationWarning)
  5. class EnginePUBHandler(PUBHandler):
  6. """A simple PUBHandler subclass that sets root_topic"""
  7. engine=None
  8. def __init__(self, engine, *args, **kwargs):
  9. PUBHandler.__init__(self,*args, **kwargs)
  10. self.engine = engine
  11. @property
  12. def root_topic(self):
  13. """this is a property, in case the handler is created
  14. before the engine gets registered with an id"""
  15. if isinstance(getattr(self.engine, 'id', None), int):
  16. return "engine.%i"%self.engine.id
  17. else:
  18. return "engine"