コード例 #1
0
def scan_events(
    message_url,
    message_exchange,
    priority,
    highest_priority_duration,
    maximum_priority):
  priority_duration = (2 ** priority) * highest_priority_duration
  message_client = message_queue.create_message_client(message_url)
  current_id = ""

  while True:
    with db.Context():
      event_count = _query_event_count(priority)
      event_interval = highest_priority_duration
      if event_count != 0:
        event_interval = priority_duration / event_count
      logging.info("Sleepging for %s seconds for priorrity %s",
                   total_seconds(event_interval),
                   priority)

      time.sleep(total_seconds(event_interval))

      view_result = _query_event(current_id, priority)
      current_id = _send_update_message_from_event(message_client, message_exchange, view_result)
      _decrease_priority(view_result, maximum_priority)
コード例 #2
0
ファイル: test_commons.py プロジェクト: Thisisdotme/thisis.me
 def test_total_seconds(self):
   time_delta = datetime.timedelta(1, 5, 40)
   self.assertEqual(total_seconds(time_delta), 86405.00004)