title: How to create a custom timer triggered iotedge function in python?
body: <p>My requirement is to gather data on my device every 5th minute.
  This resembles a function app which is triggered every 5th minute.
  My device has limited resources, and i wish to do this with Python.</p>
  <p>I have tried something similar to this, which sleeps until clock is a multiple of 5.</p>
  <pre><code>from azure.iot.device.aio import IoTHubModuleClient
  from azure.iot.device import Message
  from six.moves import input
  import asyncio
  from datetime import datetime, timedelta
  async def main():
      sample_interval = 5
      executionTime = datetime.utcnow()
      try:
          nextSample = executionTime + timedelta(minutes=5)
          secondsUntilSampleInterval = (nextSample - datetime.utcnow()).seconds
  
          while True:
              print(&quot;module is connected: &quot; + str(module_client.connected))
              if not module_client.connected:
                  await module_client.connect()
              
              await asyncio.gather(asyncio.sleep(secondsUntilSampleInterval), GatherData())
              secondsUntilSampleInterval = sample_interval*60
      except Exception as e:
          print(&quot;Unexpected error %s &quot; % e)
          raise
  </code></pre>
  <p>However this does not meet my demands as it drifts over time.</p>
  <p>I wish to have the GatherData function triggered when the clock is 10:00, 10:05, 10:10, ...</p>
  <p>EDIT:
  I forgot to mention that the GatherData function is async.</p>