stevieb has asked for the wisdom of the Perl Monks concerning the following question:

Greetings and good day my fellow esteemed Monks.

I come today with a Dancer2 and simultaneous asynchronous request question(s). I have a microcontroller (Wemos D1 mini with an ESP8266 chip) in my garage that presents data about my Tesla vehicle state on an OLED screen and a strip of LEDs. Here's how it works:

What I want to have happen, is something like this:

Essentially, I want the Pi to asynchronously request data from Tesla's API about my vehicle, respond with the last (global) poll data before the current (Tesla API) request is done (effectively terminating the HTTP connection), then update the global variable that contains the vehicle data when the async Tesla API call is complete for the next microcontroller call.

How can I respond back to the microcontroller with previous data before the current Tesla API call is completed?

Also, how can I ensure that if the first async Tesla API call is done before spawning off a second one (ie. if two seconds have elapsed and a new microcontroller check comes in and the async process isn't finished from last time), respond with the existing data without respawning a new async process?