# Buggy code
def keep_learning_about_nodes(self):
    """
    Continually learn about new nodes.
    """

    # TODO: Allow the user to set eagerness?  1712
    # TODO: Also, if we do allow eager, don't even defer; block right here.

    self._learning_deferred = Deferred(
        canceller=self._discovery_canceller
    )  # TODO: No longer relevant.

    def _discover_or_abort(_first_result):
        self.log.debug(f"{self} learning at {datetime.datetime.now()}")
        result = self.learn_from_teacher_node(
            eager=False, canceller=self._discovery_canceller
        )
        self.log.debug(f"{self} finished learning at {datetime.datetime.now()}")
        return result

    self._learning_deferred.addCallback(_discover_or_abort)
    self._learning_deferred.addErrback(self.handle_learning_errors)

    # Instead of None, we might want to pass something useful about the context.
    # Alternately, it might be nice for learn_from_teacher_node to (some or all of the time) return a Deferred.
    reactor.callInThread(self._learning_deferred.callback, None)
    return self._learning_deferred


# Traceback (AttributeError)
Traceback (most recent call last):
File "/home/tux/code/nucypher-prod/venv/bin/nucypher", line 33, in <module>
sys.exit(load_entry_point('nucypher', 'console_scripts', 'nucypher')())
File "/home/tux/code/nucypher-prod/venv/lib/python3.8/site-packages/click/core.py", line 829, in __call__
return self.main(*args, **kwargs)
File "/home/tux/code/nucypher-prod/venv/lib/python3.8/site-packages/click/core.py", line 782, in main
rv = self.invoke(ctx)
File "/home/tux/code/nucypher-prod/venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/tux/code/nucypher-prod/venv/lib/python3.8/site-packages/click/core.py", line 1259, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
File "/home/tux/code/nucypher-prod/venv/lib/python3.8/site-packages/click/core.py", line 1066, in invoke
return ctx.invoke(self.callback, **ctx.params)
File "/home/tux/code/nucypher-prod/venv/lib/python3.8/site-packages/click/core.py", line 610, in invoke
return callback(*args, **kwargs)
File "/home/tux/code/nucypher-prod/nucypher/cli/options.py", line 163, in wrapper
return func(**kwargs)
File "/home/tux/code/nucypher-prod/nucypher/cli/options.py", line 163, in wrapper
return func(**kwargs)
File "/home/tux/code/nucypher-prod/nucypher/cli/options.py", line 163, in wrapper
return func(**kwargs)
[Previous line repeated 1 more time]
File "/home/tux/code/nucypher-prod/nucypher/cli/commands/stake.py", line 1263, in set_min_rate
paint_min_rate(emitter, STAKEHOLDER.registry, STAKEHOLDER.policy_agent, staking_address)
File "/home/tux/code/nucypher-prod/nucypher/cli/painting/staking.py", line 229, in paint_min_rate
minimum = policy_agent.min_fee_rate(staker_address)
AttributeError: 'PolicyManagerAgent' object has no attribute 'min_fee_rate'

# Fixed code
def keep_learning_about_nodes(self):
    """
    Continually learn about new nodes.
    """

    # TODO: Allow the user to set eagerness?  1712
    # TODO: Also, if we do allow eager, don't even defer; block right here.

    self._learning_deferred = Deferred(
        canceller=self._discovery_canceller
    )  # TODO: No longer relevant.

    def _discover_or_abort(_first_result):
        # self.log.debug(f"{self} learning at {datetime.datetime.now()}")   # 1712
        result = self.learn_from_teacher_node(
            eager=False, canceller=self._discovery_canceller
        )
        # self.log.debug(f"{self} finished learning at {datetime.datetime.now()}")  # 1712
        return result

    self._learning_deferred.addCallback(_discover_or_abort)
    self._learning_deferred.addErrback(self.handle_learning_errors)

    # Instead of None, we might want to pass something useful about the context.
    # Alternately, it might be nice for learn_from_teacher_node to (some or all of the time) return a Deferred.
    reactor.callInThread(self._learning_deferred.callback, None)
    return self._learning_deferred