Skip to content

Daemon

A persistent background process that keeps a CarverSession alive for low-latency calls from Grasshopper or other clients. Communicates via Python's multiprocessing.connection over localhost with a random authkey.

The daemon is started and stopped via the CLI (urbansolarcarver daemon start/stop) or from within Grasshopper using the USC_Session component. It binds to 127.0.0.1 only and is not network-accessible.

urbansolarcarver.daemon

CUDA/Warp session persistence server for IPC (Grasshopper, Revit).

Keeps the GPU context alive across multiple calls from external applications. Starts a single CarverSession and listens for JSON-like RPC messages over a multiprocessing Connection, dispatching each request to the appropriate pipeline entry point and returning serialised results.

Security assumptions
  • Localhost only — the daemon binds exclusively to the loopback interface. Non-loopback addresses are rejected at startup.
  • Authkey — a random 32-byte token is generated on first start and stored in .daemon_authkey. Clients must present this key.
  • Pickle IPCmultiprocessing.connection uses pickle internally. Any process that holds the authkey can execute arbitrary code in the daemon's context. This is acceptable because both endpoints run on the same machine under the same user account.
  • Not designed for multi-tenant or server deployment. Do not expose the daemon port to a network.

serve(address, authkey, device_arg='auto')

Start the persistent RPC listener for CUDA/Warp session reuse.

Binds a multiprocessing.connection Listener on (host, port) and dispatches incoming commands to the 3-stage pipeline (preprocessing, thresholding, exporting) or to session management (shutdown). Each pipeline command runs within a CarverSession context that keeps the CUDA context and compiled Warp kernels alive across calls, avoiding the ~5s GPU startup penalty on each invocation from Grasshopper or Revit.

The session's tensor cache is invalidated between runs (bump()) but kernels persist for the lifetime of the daemon process.