diff --git a/index.json b/index.json index bd993c4..bb9d90d 100644 --- a/index.json +++ b/index.json @@ -1,12 +1,7 @@ { "plugin_manager_url": "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugin_manager.py", "versions": { - "0.1.7": { - "api_version": 7, - "commit_sha": "09991f7", - "released_on": "03-10-2022", - "md5sum": "283fdf4b1b16102d77b8b67615780d5d" - }, + "0.1.7": null, "0.1.6": { "api_version": 7, "commit_sha": "2a7ad8e", @@ -32,4 +27,4 @@ "http://github.com/bombsquad-community/plugin-manager/{content_type}/{tag}/plugins/maps.json" ], "external_source_url": "http://github.com/{repository}/{content_type}/{tag}/category.json" -} \ No newline at end of file +} diff --git a/plugin_manager.py b/plugin_manager.py index eef9e53..618b139 100644 --- a/plugin_manager.py +++ b/plugin_manager.py @@ -920,6 +920,7 @@ class PluginManager: self._index = _CACHE.get("index", {}) self.categories = {} self.module_path = sys.modules[__name__].__file__ + self._index_setup_in_progress = False async def get_index(self): if not self._index: @@ -932,13 +933,20 @@ class PluginManager: headers=self.request_headers, ) response = await async_send_network_request(request) - self._index = json.loads(response.read()) - self.set_index_global_cache(self._index) + index = json.loads(response.read()) + self.set_index_global_cache(index) + self._index = index return self._index async def setup_index(self): + while self._index_setup_in_progress: + # Avoid making multiple network calls to the same resource in parallel. + # Rather wait for the previous network call to complete. + await asyncio.sleep(0.1) + self._index_setup_in_progress = not bool(self._index) index = await self.get_index() await self.setup_plugin_categories(index) + self._index_setup_in_progress = False async def setup_plugin_categories(self, plugin_index): # A hack to have the "All" category show at the top.