silkworm.settings¶
Layered engine settings for runners and the command line.
Engine options resolve from four layers, lowest precedence first:
Enginedefaults.Environment variables named
SILKWORM_<OPTION>(for exampleSILKWORM_CONCURRENCY=32orSILKWORM_MAX_DEPTH=3).The spider’s
custom_settingsentries whose keys name engine options.Options passed explicitly to a runner or on the command line.
Only scalar options (numbers, booleans, strings, and paths) can come from the
environment or custom_settings; middlewares, pipelines, and clients are
always passed in code. Values are validated and converted, so a typo such as
SILKWORM_MAX_DEPTH=three fails with a clear error instead of being ignored.
Engine itself never reads these layers; use
resolve_options() (as the runners do) to apply them.
- silkworm.settings.coerce_setting(name, value, *, source='setting')[source]¶
Validate and convert
valuefor engine optionname.- Parameters:
- Raises:
KeyError – If
nameis not a configurable engine option.ValueError – If the value cannot be converted.
- Return type:
- silkworm.settings.resolve_options(spider, options, *, environ=None)[source]¶
Merge the settings layers into the options passed to
Engine.- Parameters:
spider (Spider) – Spider whose
custom_settingsform the third layer.options (EngineOptions | Mapping[str, object]) – Explicit options; these always win.
environ (Mapping[str, str] | None) – Environment mapping; defaults to
os.environ.
- Return type: