title: Cannot run a While Loop in AWS Python Lambda
body: <pre><code>import asyncio
  from aiogram import Bot, Dispatcher, types
  
  # Handlers
  async def echo_hello(message: types.Message):
      while True:
          await message.reply(&quot;Hello!&quot;)
          await asyncio.sleep(20)
          
  # AWS Lambda funcs
  async def register_handlers(dp: Dispatcher):
      dp.register_message_handler(echo_hello, commands=['sayhello'])
  
  async def process_event(event, dp: Dispatcher):
      Bot.set_current(dp.bot)
      update = types.Update.to_object(event)
      await dp.process_update(update)
  
  
  async def main(event):
      bot = Bot(token=TOKEN)
      dp = Dispatcher(bot)
  
      await register_handlers(dp)
      await process_event(event, dp)
  
      return 'ok'
  
  
  def lambda_handler(event, context):
      return asyncio.get_event_loop().run_until_complete(main(event))
  </code></pre>
  <p>I can't seem to get my telegram bot in AWS Python Lambda to loop the Hello message. Provided I got no idea how else to get the lambda_handler function, I only saw this as an example from <a href="https://github.com/DavisDmitry/aiogram-aws-serverless-example" rel="nofollow noreferrer">https://github.com/DavisDmitry/aiogram-aws-serverless-example</a></p>
  <p>EDIT: NVM the default timeout for functions is 15 minutes at best so any loop will only work for 15 minutes at the most.</p>