Skip to content

Commit

Permalink
playwright: Improve error message (and make it trigger always) for wh…
Browse files Browse the repository at this point in the history
…en LOCUST_PLAYWRIGHT is unset.
  • Loading branch information
cyberw committed Jul 23, 2023
1 parent 69e449e commit 36aa41c
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions locust_plugins/users/playwright.py
Original file line number Diff line number Diff line change
@@ -1,17 +1,19 @@
import logging
import os
import sys
try:
from playwright.async_api import async_playwright, Playwright, Browser, Page, BrowserContext
except NotImplementedError as e:
raise Exception(
"Could not import playwright, probably because gevent monkey patching was done before trio init. Set env var LOCUST_PLAYWRIGHT=1"
) from e
except (NotImplementedError, AttributeError) as e:
if os.getenv("LOCUST_PLAYWRIGHT", False):
raise Exception("Could not import playwright, even though LOCUST_PLAYWRIGHT was set :(") from e
else:
logging.error("Set env var LOCUST_PLAYWRIGHT=1 to make locust load trio before gevent monkey patching")
sys.exit(1)
from contextlib import asynccontextmanager, contextmanager
import logging
import os
import asyncio
from locust import User, events, task
from locust.runners import WorkerRunner
import gevent
import sys
import ast
import types
import time
Expand Down

0 comments on commit 36aa41c

Please sign in to comment.