@mock_only Feature: A2aEventQueue thread-safety (issue #7604) As a CleverAgents developer I want A2aEventQueue to be safe for concurrent use from multiple threads So that publish/subscribe/unsubscribe operations never raise RuntimeError: dictionary changed size during iteration # ----------------------------------------------------------------------- # Regression: concurrent publish + subscribe must not raise RuntimeError # ----------------------------------------------------------------------- Scenario: Concurrent publish and subscribe_local do not raise RuntimeError Given a2aconcur a fresh A2aEventQueue When a2aconcur I run concurrent publish and subscribe_local from multiple threads Then a2aconcur no RuntimeError should have been raised And a2aconcur all published events should be in the queue # ----------------------------------------------------------------------- # Regression: concurrent publish + unsubscribe must not raise RuntimeError # ----------------------------------------------------------------------- Scenario: Concurrent publish and unsubscribe do not raise RuntimeError Given a2aconcur a fresh A2aEventQueue with subscribers When a2aconcur I run concurrent publish and unsubscribe from multiple threads Then a2aconcur no RuntimeError should have been raised # ----------------------------------------------------------------------- # Regression: concurrent subscribe + unsubscribe must not raise RuntimeError # ----------------------------------------------------------------------- Scenario: Concurrent subscribe_local and unsubscribe do not raise RuntimeError Given a2aconcur a fresh A2aEventQueue When a2aconcur I run concurrent subscribe_local and unsubscribe from multiple threads Then a2aconcur no RuntimeError should have been raised # ----------------------------------------------------------------------- # Lock is present on new instances # ----------------------------------------------------------------------- Scenario: A2aEventQueue has a threading.Lock after construction Given a2aconcur a fresh A2aEventQueue Then a2aconcur the queue should have a threading Lock attribute # ----------------------------------------------------------------------- # publish snapshots subscriptions so late-arriving unsubscribe is safe # ----------------------------------------------------------------------- Scenario: Unsubscribing inside a callback does not affect the current publish iteration Given a2aconcur a fresh A2aEventQueue And a2aconcur a subscriber that unsubscribes itself during the callback When a2aconcur I publish a valid A2aEvent Then a2aconcur no RuntimeError should have been raised And a2aconcur the event should be in the queue # ----------------------------------------------------------------------- # get_events is thread-safe # ----------------------------------------------------------------------- Scenario: Concurrent publish and get_events do not raise RuntimeError Given a2aconcur a fresh A2aEventQueue When a2aconcur I run concurrent publish and get_events from multiple threads Then a2aconcur no RuntimeError should have been raised