From 742a0b1799bdeabe5dc137fb37c112e9cffd7d46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Vinot?= Date: Thu, 1 Sep 2022 18:20:29 +0200 Subject: [PATCH] fix: Exception when we try to update the UAs from within a PW context --- lookyloo/helpers.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lookyloo/helpers.py b/lookyloo/helpers.py index 485a49ce..f67b3097 100644 --- a/lookyloo/helpers.py +++ b/lookyloo/helpers.py @@ -96,6 +96,11 @@ class UserAgents: ua_files_path = sorted(self.path.glob('**/*.json'), reverse=True) self._load_newest_ua_file(ua_files_path[0]) + # This call *must* be here because otherwise, we get the devices from within the async + # process and as we already have a playwright context, it fails. + # it is not a problem to have it here because the devices do not change + # until we have a new version playwright, and restart everything anyway. + self.playwright_devices = get_devices() def _load_newest_ua_file(self, path: Path): self.most_recent_ua_path = path @@ -105,7 +110,6 @@ class UserAgents: self._load_playwright_devices() def _load_playwright_devices(self): - self.playwright_devices = get_devices() # Only get default and desktop for now. for device_name, details in self.playwright_devices['desktop']['default'].items(): parsed_ua = ParsedUserAgent(details['user_agent'])