Further decouple some plugin fetch tasks from initial startup thread
This commit is contained in:
parent
3bfc4725d2
commit
c91fe0c4fc
4 changed files with 26 additions and 6 deletions
|
|
@ -41,7 +41,13 @@ class AnnouncementPlugin(octoprint.plugin.AssetPlugin,
|
|||
# StartupPlugin
|
||||
|
||||
def on_after_startup(self):
|
||||
self._fetch_all_channels()
|
||||
# decouple channel fetching from server startup
|
||||
def fetch_data():
|
||||
self._fetch_all_channels()
|
||||
|
||||
thread = threading.Thread(target=fetch_data)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
# SettingsPlugin
|
||||
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ import pkg_resources
|
|||
import copy
|
||||
import dateutil.parser
|
||||
import time
|
||||
import threading
|
||||
|
||||
class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
||||
octoprint.plugin.TemplatePlugin,
|
||||
|
|
@ -95,8 +96,14 @@ class PluginManagerPlugin(octoprint.plugin.SimpleApiPlugin,
|
|||
self._console_logger.setLevel(logging.DEBUG)
|
||||
self._console_logger.propagate = False
|
||||
|
||||
self._repository_available = self._fetch_repository_from_disk()
|
||||
self._notices_available = self._fetch_notices_from_disk()
|
||||
# decouple repository fetching from server startup
|
||||
def fetch_data():
|
||||
self._repository_available = self._fetch_repository_from_disk()
|
||||
self._notices_available = self._fetch_notices_from_disk()
|
||||
|
||||
thread = threading.Thread(target=fetch_data)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
##~~ SettingsPlugin
|
||||
|
||||
|
|
|
|||
|
|
@ -78,8 +78,14 @@ class SoftwareUpdatePlugin(octoprint.plugin.BlueprintPlugin,
|
|||
self._console_logger.propagate = False
|
||||
|
||||
def on_after_startup(self):
|
||||
# refresh cache now if necessary so it's faster once the user connects to the instance
|
||||
self.get_current_versions()
|
||||
# refresh cache now if necessary so it's faster once the user connects to the instance - but decouple it from
|
||||
# the server startup
|
||||
def fetch_data():
|
||||
self.get_current_versions()
|
||||
|
||||
thread = threading.Thread(target=fetch_data)
|
||||
thread.daemon = True
|
||||
thread.start()
|
||||
|
||||
def _get_configured_checks(self):
|
||||
with self._configured_checks_mutex:
|
||||
|
|
|
|||
|
|
@ -819,6 +819,7 @@ class Server(object):
|
|||
kwargs.update(additional_request_data)
|
||||
|
||||
try:
|
||||
start = time.time()
|
||||
if plugin:
|
||||
logger.info("Preemptively caching {} (ui {}) for {!r}".format(route, plugin, kwargs))
|
||||
else:
|
||||
|
|
@ -832,7 +833,7 @@ class Server(object):
|
|||
builder = EnvironBuilder(**kwargs)
|
||||
app(builder.get_environ(), lambda *a, **kw: None)
|
||||
|
||||
logger.info("... done.".format(route, plugin, kwargs))
|
||||
logger.info("... done in {:.2f}s".format(time.time() - start))
|
||||
except:
|
||||
logger.exception("Error while trying to preemptively cache {} for {!r}".format(route, kwargs))
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue