<commit_before>module Dynflow
  module Action::Polling

    Poll = Algebrick.atom

    def run(event = nil)
      case event
      when nil
        self.external_task = invoke_external_task
        suspend_and_ping
      when Poll
        self.external_task = poll_external_task
        suspend_and_ping unless done?
      else
        raise "unrecognized event #{event}"
      end
    end

    private

    def invoke_external_task
      raise NotImplementedError
    end

    def external_task=(external_task_data)
      raise NotImplementedError
    end

    def external_task
      raise NotImplementedError
    end

    def poll_external_task
      raise NotImplementedError
    end

    def done?
      raise NotImplementedError
    end

    def suspend_and_ping
      suspend { |suspended_action| world.clock.ping suspended_action, Time.now + poll_interval, Poll }
    end

    def poll_interval
      0.5
    end
  end
end
<commit_msg>no need to recalculate time for Clock#ping<commit_after>module Dynflow
  module Action::Polling

    Poll = Algebrick.atom

    def run(event = nil)
      case event
      when nil
        self.external_task = invoke_external_task
        suspend_and_ping
      when Poll
        self.external_task = poll_external_task
        suspend_and_ping unless done?
      else
        raise "unrecognized event #{event}"
      end
    end

    private

    def invoke_external_task
      raise NotImplementedError
    end

    def external_task=(external_task_data)
      raise NotImplementedError
    end

    def external_task
      raise NotImplementedError
    end

    def poll_external_task
      raise NotImplementedError
    end

    def done?
      raise NotImplementedError
    end

    def suspend_and_ping
      suspend { |suspended_action| world.clock.ping suspended_action, poll_interval, Poll }
    end

    def poll_interval
      0.5
    end
  end
end

{'fraction_non_alphanumeric': 0.03623949579831933, 'fraction_numerical': 0.0021008403361344537, 'mean_word_length': 2.3304195804195804, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '750224', 'n_tokens_mistral': 562, 'n_tokens_neox': 539, 'n_words': 149}