settled2.py (581B)
1 # This Source Code Form is subject to the terms of the Mozilla Public 2 # License, v. 2.0. If a copy of the MPL was not distributed with this 3 # file, You can obtain one at http://mozilla.org/MPL/2.0/. 4 5 import asyncio 6 7 8 async def settled2(session, options): 9 retries = 0 10 while retries < 3: 11 try: 12 await asyncio.wait_for(session.get("https://www.mozilla.org/en-US/"), 5) 13 break 14 except asyncio.TimeoutError: 15 retries += 1 16 17 # we just settle here for 5 minutes 18 await asyncio.sleep(options.get("sleep", 5 * 60)) 19 return {}