#1170·abstreet

Python API client example crashes the headless simulation

Author: ian-pCreated Nov 22, 2025Updated Nov 24, 2025

Hi,

Running the api client example crashes the simulation. I saw in the other issue that traffic sim is not maintained anymore. Does the error seem like something that happens because of the map (everything's default in my case). If so, is there a way to "fix" the map to not cause the crash, or does this look like a deeper issue?

branch: main
commit 0964f29315820c91b171b585eb51e300164e9197 (HEAD -> main, origin/main, origin/HEAD)
Author: pdobacz <[email protected]>
Date:   Wed Sep 10 08:24:40 2025 +0200
bash
git:(main) rustc --version
rustc 1.91.1 (ed61e7d7e 2025-11-07) (Homebrew)
git:(main) cargo --version
cargo 1.91.1 (Homebrew)
git:(main) sw_vers
ProductName:		macOS
ProductVersion:		15.7.2
BuildVersion:		24G325
git:(main) rustc -vV
rustc 1.91.1 (ed61e7d7e 2025-11-07) (Homebrew)
binary: rustc
commit-hash: ed61e7d7e242494fb7057f2657300d9e77bb4fcb
commit-date: 2025-11-07
host: aarch64-apple-darwin
release: 1.91.1
LLVM version: 21.1.5
git:(main) uname -m
arm64
bash
python python_client.py
Did you just start the simulation? Time is currently 00:00:00.0
Reset the simulation: sim reloaded

Simulating before any edits
Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 537, in _make_request
    response = conn.getresponse()
               ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connection.py", line 466, in getresponse
    httplib_response = super().getresponse()
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1395, in getresponse
    response.begin()
  File "/opt/homebrew/Cellar/[email protected]/3.11.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 325, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 294, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
http.client.RemoteDisconnected: Remote end closed connection without response

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.11/site-packages/requests/adapters.py", line 667, in send
    resp = conn.urlopen(
           ^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 847, in urlopen
    retries = retries.increment(
              ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/util/retry.py", line 470, in increment
    raise reraise(type(error), error, _stacktrace)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/util/util.py", line 38, in reraise
    raise value.with_traceback(tb)
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 793, in urlopen
    response = self._make_request(
               ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connectionpool.py", line 537, in _make_request
    response = conn.getresponse()
               ^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/urllib3/connection.py", line 466, in getresponse
    httplib_response = super().getresponse()
                       ^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 1395, in getresponse
    response.begin()
  File "/opt/homebrew/Cellar/[email protected]/3.11.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 325, in begin
    version, status, reason = self._read_status()
                              ^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/Cellar/[email protected]/3.11.11/Frameworks/Python.framework/Versions/3.11/lib/python3.11/http/client.py", line 294, in _read_status
    raise RemoteDisconnected("Remote end closed connection without"
urllib3.exceptions.ProtocolError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/i/projects/inv-game/mapy/build/headless/examples/python_client.py", line 148, in <module>
    main()
  File "/Users/i/projects/inv-game/mapy/build/headless/examples/python_client.py", line 25, in main
    trips1, delays1, thruput1 = run_experiment()
                                ^^^^^^^^^^^^^^^^
  File "/Users/i/projects/inv-game/mapy/build/headless/examples/python_client.py", line 105, in run_experiment
    print(requests.get(api + '/sim/goto-time',
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/requests/api.py", line 73, in get
    return request("get", url, params=params, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/requests/api.py", line 59, in request
    return session.request(method=method, url=url, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/requests/sessions.py", line 589, in request
    resp = self.send(prep, **send_kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/requests/sessions.py", line 703, in send
    r = adapter.send(request, **kwargs)
        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/opt/homebrew/lib/python3.11/site-packages/requests/adapters.py", line 682, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', RemoteDisconnected('Remote end closed connection without response'))
bash
RUST_BACKTRACE=1 cargo run --release --bin headless -- --port=1234
warning: hiding a lifetime that's elided elsewhere is confusing
   --> map_model/src/pathfind/engine.rs:102:27
    |
102 |     pub fn reuse_ordering(&self) -> CreateEngine {
    |                           ^^^^^     ^^^^^^^^^^^^ the same lifetime is hidden here
    |                           |
    |                           the lifetime is elided here
    |
    = help: the same lifetime is referred to in inconsistent ways, making the signature confusing
    = note: `#[warn(mismatched_lifetime_syntaxes)]` on by default
help: use `'_` for type paths
    |
102 |     pub fn reuse_ordering(&self) -> CreateEngine<'_> {
    |                                                 ++++

warning: `map_model` (lib) generated 1 warning (run `cargo fix --lib -p map_model` to apply 1 suggestion)
    Finished `release` profile [optimized] target(s) in 0.72s
     Running `target/release/headless --port=1234`
setup headless...
Read data/system/us/seattle/scenarios/montlake/weekday.bin (1)... 0.0324s
Read data/system/us/seattle/maps/montlake.bin (3)... 0.0406s
generate movements (754)... 0.0013s
create blank sim...
setup offstreet parking (3,102)... 0.0021s
create blank sim... plus 0.0018s
create blank sim took 0.0039s
[2025-11-22T16:47:01Z INFO  abstutil::time] - create blank sim took 0.0039s
[2025-11-22T16:47:01Z INFO  abstutil::time]   - setup offstreet parking (3,102)... 0.0021s
[2025-11-22T16:47:01Z INFO  abstutil::time]   - ... plus 0.0018s
Instantiating weekday...
trips for People (13,484)... 0.0044s
[2025-11-22T16:47:01Z WARN  sim::sim::scenario] Not enough room to seed parked cars. Only found spots for 5,000 of 5,064
seed parked cars (5,064)... 0.0693s
spawn trips (36,614)... 0.0203s
Instantiating weekday... plus 0.0017s
Instantiating weekday took 0.0956s
setup headless... plus 0.0055s
setup headless took 0.1755s
[2025-11-22T16:47:01Z INFO  abstutil::time] - setup headless took 0.1755s
[2025-11-22T16:47:01Z INFO  abstutil::time]   - Read data/system/us/seattle/scenarios/montlake/weekday.bin (1)... 0.0324s
[2025-11-22T16:47:01Z INFO  abstutil::time]   - Read data/system/us/seattle/maps/montlake.bin (3)... 0.0406s
[2025-11-22T16:47:01Z INFO  abstutil::time]   - generate movements (754)... 0.0013s
[2025-11-22T16:47:01Z INFO  abstutil::time]   - Instantiating weekday took 0.0956s
[2025-11-22T16:47:01Z INFO  abstutil::time]     - trips for People (13,484)... 0.0044s
[2025-11-22T16:47:01Z INFO  abstutil::time]     - seed parked cars (5,064)... 0.0693s
[2025-11-22T16:47:01Z INFO  abstutil::time]     - spawn trips (36,614)... 0.0203s
[2025-11-22T16:47:01Z INFO  abstutil::time]     - ... plus 0.0017s
[2025-11-22T16:47:01Z INFO  abstutil::time]   - ... plus 0.0055s
create blank sim...
create blank sim took 0.0001s
[2025-11-22T16:47:01Z INFO  abstutil::time] - create blank sim took 0.0001s
[2025-11-22T16:47:01Z INFO  headless] Listening on http://127.0.0.1:1234
[2025-11-22T16:47:07Z INFO  headless] Handling /sim/get-time
[2025-11-22T16:47:07Z INFO  headless] Handling /sim/reset
reset sim...
Read data/system/us/seattle/scenarios/montlake/weekday.bin (1)... 0.0134s
Read data/system/us/seattle/maps/montlake.bin (3)... 0.0268s
generate movements (754)... 0.0013s
create blank sim...
setup offstreet parking (3,102)... 0.0021s
create blank sim... plus 0.0017s
create blank sim took 0.0038s
[2025-11-22T16:47:07Z INFO  abstutil::time] - create blank sim took 0.0038s
[2025-11-22T16:47:07Z INFO  abstutil::time]   - setup offstreet parking (3,102)... 0.0021s
[2025-11-22T16:47:07Z INFO  abstutil::time]   - ... plus 0.0017s
Instantiating weekday...
trips for People (13,484)... 0.0038s
[2025-11-22T16:47:07Z WARN  sim::sim::scenario] Not enough room to seed parked cars. Only found spots for 5,000 of 5,064
seed parked cars (5,064)... 0.0676s
spawn trips (36,614)... 0.0204s
Instantiating weekday... plus 0.0013s
Instantiating weekday took 0.0931s
reset sim... plus 0.0048s
reset sim took 0.1394s
[2025-11-22T16:47:07Z INFO  abstutil::time] - reset sim took 0.1394s
[2025-11-22T16:47:07Z INFO  abstutil::time]   - Read data/system/us/seattle/scenarios/montlake/weekday.bin (1)... 0.0134s
[2025-11-22T16:47:07Z INFO  abstutil::time]   - Read data/system/us/seattle/maps/montlake.bin (3)... 0.0268s
[2025-11-22T16:47:07Z INFO  abstutil::time]   - generate movements (754)... 0.0013s
[2025-11-22T16:47:07Z INFO  abstutil::time]   - Instantiating weekday took 0.0931s
[2025-11-22T16:47:07Z INFO  abstutil::time]     - trips for People (13,484)... 0.0038s
[2025-11-22T16:47:07Z INFO  abstutil::time]     - seed parked cars (5,064)... 0.0676s
[2025-11-22T16:47:07Z INFO  abstutil::time]     - spawn trips (36,614)... 0.0204s
[2025-11-22T16:47:07Z INFO  abstutil::time]     - ... plus 0.0013s
[2025-11-22T16:47:07Z INFO  abstutil::time]   - ... plus 0.0048s
[2025-11-22T16:47:07Z INFO  headless] Handling /sim/goto-time
goto-time...
Advance sim to 12:00:00.0...
Alert at 00:18:02.4 (Person(PersonID(5792))): Car #5114 can't find parking on Lane #2370 or anywhere reachable from it. Possibly we're just totally out of parking space!
Alert at 00:19:27.0 (Person(PersonID(7729))): Car #6790 can't find parking on Lane #21698 or anywhere reachable from it. Possibly we're just totally out of parking space!
Alert at 00:20:43.4 (Person(PersonID(8844))): Car #7726 can't find parking on Lane #21698 or anywhere reachable from it. Possibly we're just totally out of parking space!
Alert at 00:20:59.9 (Person(PersonID(4241))): Car #3683 can't find parking on Lane #21698 or anywhere reachable from it. Possibly we're just totally out of parking space!

(....)

Alert at 10:36:14.1 (Intersection(IntersectionID(53))): AgentID(Car #9988) waking up AgentID(Car #10944), who's blocking it as part of a cycle
Alert at 10:36:14.1 (Intersection(IntersectionID(366))): AgentID(Car #10944) found turn conflict cycle involving {CarID { id: 10944, vehicle_type: Car }, CarID { id: 9988, vehicle_type: Car }}
Alert at 10:36:14.1 (Intersection(IntersectionID(366))): AgentID(Car #10944) waking up AgentID(Car #9988), who's blocking it as part of a cycle
Alert at 10:37:00.0 (Person(PersonID(5660))): Person 5660 had a trip cancelled, and their car was warped to Onstreet(LaneID { road: RoadID(78), offset: 1 }, 1)

thread 'tokio-runtime-worker' (4766406) panicked at sim/src/mechanics/intersection.rs:1039:45:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: __rustc::rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: sim::mechanics::intersection::IntersectionSimState::handle_accepted_conflicts
   5: sim::mechanics::intersection::IntersectionSimState::maybe_start_turn
   6: sim::mechanics::driving::DrivingSimState::update_car
   7: sim::sim::Sim::minimal_step
   8: sim::sim::Sim::timed_step
   9: headless::handle_command
  10: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_loop
  11: hyper::proto::h1::dispatch::Dispatcher<D,Bs,I,T>::poll_catch
  12: <hyper::server::conn::upgrades::UpgradeableConnection<I,S,E> as core::future::future::Future>::poll
  13: <hyper::server::server::new_svc::NewSvcTask<I,N,S,E,W> as core::future::future::Future>::poll
  14: tokio::runtime::task::core::Core<T,S>::poll
  15: tokio::runtime::task::harness::Harness<T,S>::poll
  16: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
  17: tokio::runtime::scheduler::multi_thread::worker::Context::run
  18: tokio::runtime::context::scoped::Scoped<T>::set
  19: tokio::runtime::context::runtime::enter_runtime
  20: tokio::runtime::scheduler::multi_thread::worker::run
  21: tokio::runtime::task::core::Core<T,S>::poll
  22: tokio::runtime::task::harness::Harness<T,S>::poll
  23: tokio::runtime::blocking::pool::Inner::run
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.