def heartbeat(self):
        '''Record the current worker state in the registry.

        This records the worker's current mode, plus the contents of
        :meth:`environment`, in the data store for inspection by others.

        :returns mode: Current mode, as :meth:`TaskMaster.get_mode`

        '''
        mode = self.task_master.get_mode()
        self.task_master.worker_heartbeat(self.worker_id, mode,
                                          self.lifetime, self.environment(),
                                          parent=self.parent)
        return mode
Record the current worker state in the registry.

        This records the worker's current mode, plus the contents of
        :meth:`environment`, in the data store for inspection by others.

        :returns mode: Current mode, as :meth:`TaskMaster.get_mode`