From cd4b5604b3926523b067b87394908d89175134f0 Mon Sep 17 00:00:00 2001 From: Matt McFarland Date: Tue, 25 Oct 2022 17:18:10 -0400 Subject: [PATCH] Remove sleep call in pcfunc tile fetching (#132) The sleep call did have an effect of spreading out requests over time, but in an arbitrary and non-efficient manner. The semaphore context block effectively blocks on a counter-based lock. --- pc-funcs.dev.env | 6 +++--- pcfuncs/funclib/tiles.py | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/pc-funcs.dev.env b/pc-funcs.dev.env index b61c2b61..87bf075c 100644 --- a/pc-funcs.dev.env +++ b/pc-funcs.dev.env @@ -3,10 +3,10 @@ WEBSITE_HOSTNAME=funcs:8083 ANIMATION_OUTPUT_STORAGE_URL="http://azurite:10000/devstoreaccount1/output/animations" ANIMATION_OUTPUT_ACCOUNT_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" -ANIMATION_API_ROOT_URL="https://planetarycomputer.microsoft.com/api/data/v1" +ANIMATION_API_ROOT_URL="https://planetarycomputer-staging.microsoft.com/api/data/v1" ANIMATION_TILE_REQUEST_CONCURRENCY=2 IMAGE_OUTPUT_STORAGE_URL="http://azurite:10000/devstoreaccount1/output/images" IMAGE_OUTPUT_ACCOUNT_KEY="Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==" -IMAGE_API_ROOT_URL="https://planetarycomputer.microsoft.com/api/data/v1" -IMAGE_TILE_REQUEST_CONCURRENCY=2 \ No newline at end of file +IMAGE_API_ROOT_URL="https://planetarycomputer-staging.microsoft.com/api/data/v1" +IMAGE_TILE_REQUEST_CONCURRENCY=2 diff --git a/pcfuncs/funclib/tiles.py b/pcfuncs/funclib/tiles.py index 535aadad..4211bbf3 100644 --- a/pcfuncs/funclib/tiles.py +++ b/pcfuncs/funclib/tiles.py @@ -162,11 +162,6 @@ async def _f() -> io.BytesIO: async with aiohttp.ClientSession() as session: async with self._async_limit: async with session.get(url) as resp: - # Download the image tile, block if exceeding concurrency limits - if self._async_limit.locked(): - logger.info("Concurrency limit reached, waiting...") - await asyncio.sleep(1) - if resp.status == 200: return io.BytesIO(await resp.read()) else: