INTO-CPS-Association / INTO-CPS-Association/simulation-bridge
Next Matlab Agent PR
- Dominant language
- Python
- Stars
- 7
- Forks
- 4
- PR merge metrics
- No merged PRs in 30d
Description
A possible solution can be:
1) Asynchronous RabbitMQ loop
Use aio_pika instead of pika.BlockingConnection.
All RabbitMQ logic (consuming and publishing) runs in the main thread, inside an asyncio event loop.
2) Simulations run in a separate thread
When a simulation message arrives, the handle_*_simulation() function is executed in a worker thread using asyncio.to_thread().
3) The simulation thread does not publish results to RabbitMQ directly.
Instead, it puts the results into a shared asyncio.Queue, and the main thread reads from the queue and publishes the messages.
(I’m a bit unsure if this queue mechanism could significantly affect performance.)
4) A threading.Event object is used to signal a STOP to the simulation thread.
The simulation thread can check this event periodically and stop the execution cleanly if needed.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.