{"id":7425,"library":"molotov","title":"Molotov","description":"Molotov is a simple, Python 3.7+ tool for writing load tests. It is built upon `asyncio` and `aiohttp.client`, enabling highly concurrent testing scenarios. The current version is 2.6, released in October 2022. While there isn't a fixed release cadence, updates address Python compatibility, dependency changes, and new features.","status":"active","version":"2.6","language":"en","source_language":"en","source_url":"https://github.com/tarekziade/molotov","tags":["load testing","performance testing","asyncio","aiohttp","web testing"],"install":[{"cmd":"pip install molotov","lang":"bash","label":"Install stable version"}],"dependencies":[{"reason":"Core HTTP client for asynchronous requests.","package":"aiohttp","optional":false},{"reason":"Used for multiprocessing, replaced 'multiprocessing_on_dill' in 2.6.","package":"multiprocess","optional":false}],"imports":[{"note":"The primary decorator for defining load test scenarios.","symbol":"scenario","correct":"from molotov import scenario"},{"note":"Decorator for worker-level setup.","symbol":"setup","correct":"from molotov import setup"},{"note":"Decorator for test-wide setup, executed once before processes and workers.","symbol":"global_setup","correct":"from molotov import global_setup"},{"note":"Used to access session-specific data within scenarios or fixtures.","symbol":"get_context","correct":"from molotov import get_context"}],"quickstart":{"code":"import os\nfrom molotov import scenario\n\n_API = os.environ.get('MOLOTOV_TARGET_API', 'http://localhost:8080')\n\n@scenario(weight=40)\nasync def scenario_one(session):\n    async with session.get(_API) as resp:\n        res = await resp.json()\n        assert res[\"result\"] == \"OK\"\n        assert resp.status == 200\n\n@scenario(weight=60)\nasync def scenario_two(session):\n    async with session.get(_API) as resp:\n        assert resp.status == 200\n","lang":"python","description":"This quickstart defines two asynchronous scenarios that make GET requests to a target API. Each scenario receives an `aiohttp.ClientSession` object. The `weight` parameter controls the probability of a scenario being picked. To run, save this as `loadtest.py` and execute from the terminal."},"warnings":[{"fix":"Upgrade your Python environment to 3.7+ (e.g., Python 3.10 for optimal compatibility with Molotov 2.5+).","message":"Molotov version 2.5 dropped support for Python 3.6. Version 2.0 dropped support for Python 3.5. Ensure you are running Python 3.7 or superior for Molotov 2.6.","severity":"breaking","affected_versions":"2.0, 2.5+"},{"fix":"Review any custom multiprocessing logic in your test scripts; ensure compatibility with the `multiprocess` library.","message":"In Molotov 2.6, the internal multiprocessing library switched from `multiprocessing_on_dill` to `multiprocess`. While typically backward compatible, custom extensions or complex setups interacting directly with multiprocessing internals might require adjustments.","severity":"breaking","affected_versions":"2.6+"},{"fix":"If you were relying on `aiomeasures`, migrate your metrics collection to use `aiodogstatsd` or other supported alternatives.","message":"The `aiomeasures` dependency was removed in Molotov 2.4 as the project is no longer maintained. Molotov now uses `aiodogstatsd` for statsd integration.","severity":"deprecated","affected_versions":"2.4+"},{"fix":"Run Molotov on Linux or macOS environments for reliable load testing, or within a Docker container.","message":"Molotov does not officially support Windows systems, especially concerning multiprocessing features. While basic functionality might work, distributed testing is not reliable.","severity":"gotcha","affected_versions":"All versions"},{"fix":"Remove `--disable-dns-resolver` from your Molotov command-line arguments. Configure `aiohttp` directly if specific DNS behavior is required.","message":"Molotov 2.2 removed the `--disable-dns-resolver` option, as DNS resolution is now handled by `aiohttp`.","severity":"breaking","affected_versions":"2.2+"}],"env_vars":null,"last_verified":"2026-04-16T00:00:00.000Z","next_check":"2026-07-15T00:00:00.000Z","problems":[{"fix":"Define your scenario functions as `async def my_scenario(session): ...`","cause":"Scenarios are asynchronous coroutines and must accept a `session` object as their first argument.","error":"TypeError: scenario() takes 1 positional argument but 2 were given"},{"fix":"Run `pip install molotov` to install the library.","cause":"Molotov is not installed in the current Python environment.","error":"ModuleNotFoundError: No module named 'molotov'"},{"fix":"Change the function definition from `def` to `async def`.","cause":"A function decorated with `@scenario` (or other async-expecting decorators) was defined as a regular function (`def`) instead of an asynchronous one (`async def`).","error":"molotov.errors.MolotovError: Expected a coroutine"},{"fix":"Install `certifi` and ensure your Python environment is configured to use it, or run `pip install certifi` and re-run your tests. In some cases, you might need to run a specific `Install Certificates.command` on macOS.","cause":"Python's SSL module cannot find the necessary root SSL certificates to verify HTTPS connections, common in some Python installations or virtual environments.","error":"certifi.errors.NoCACertificatesError: [SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: unable to get local issuer certificate"}]}