euromod_linking.env

Configure the euromod connector source + DLL path before it is imported.

Opt-in. If EUROMOD_CONNECTOR_SRC points at a newer connector build (one that ships the Statistics module), that directory is prepended to sys.path so import euromod resolves to it instead of the installed package. The connector locates its .NET DLLs (including EM_Statistics.dll) from the EUROMOD_PATH environment variable — set both in .env; nothing is hard-coded here.

Call configure() before the first import euromod (model_session does this at import time).

Functions

configure(→ None)

Idempotently prepend EUROMOD_CONNECTOR_SRC to sys.path if valid.

harden_dotnet_console(→ None)

Detach the .NET Console from the process's console handle.

Module Contents

euromod_linking.env.configure() None[source]

Idempotently prepend EUROMOD_CONNECTOR_SRC to sys.path if valid.

euromod_linking.env.harden_dotnet_console() None[source]

Detach the .NET Console from the process’s console handle.

The EUROMOD engine prints progress and also prints every warning to the Windows console (EM_Common.Communicator.ReportError -> Console.WriteLine). In processes without a valid console handle — services, detached/background launches — that write throws IOException: The handle is invalid and turns a harmless engine warning into a failed simulation.

Redirecting Console.Out/Error to TextWriter.Null removes the fragile channel; nothing is lost: warnings are still delivered through the connector’s structured result (simulation.errors), which run_simulation surfaces as euromod_warnings/euromod_errors.

Call after import euromod (CLR loaded); idempotent, best-effort. Set EUROMOD_KEEP_CONSOLE=1 to skip (e.g. when watching engine progress interactively).