@@ -19,6 +19,7 @@ limitations under the License.
1919#include < utility>
2020#include < vector>
2121
22+ #include " absl/time/time.h"
2223#include " tensorflow/core/lib/core/notification.h"
2324#include " tensorflow/core/lib/gtl/cleanup.h"
2425#include " tensorflow_serving/core/servable_state.h"
@@ -234,11 +235,11 @@ void ServableStateMonitor::Notify(const NotifyFn& notify_fn) {
234235 notify_fns_.push_back (notify_fn);
235236}
236237
237- bool ServableStateMonitor::WaitUntilServablesReachState (
238+ bool ServableStateMonitor::WaitUntilServablesReachStateWithTimeout (
238239 const std::vector<ServableRequest>& servables,
239- const ServableState::ManagerState goal_state,
240+ const ServableState::ManagerState goal_state, absl::Duration timeout,
240241 std::map<ServableId, ServableState::ManagerState>* const states_reached) {
241- bool reached_goal_state;
242+ bool reached_goal_state = false ;
242243 Notification notified;
243244 NotifyWhenServablesReachState (
244245 servables, goal_state,
@@ -251,10 +252,19 @@ bool ServableStateMonitor::WaitUntilServablesReachState(
251252 reached_goal_state = incoming_reached_goal_state;
252253 notified.Notify ();
253254 });
254- notified.WaitForNotification ( );
255+ notified.WaitForNotificationWithTimeout (timeout );
255256 return reached_goal_state;
256257}
257258
259+ bool ServableStateMonitor::WaitUntilServablesReachState (
260+ const std::vector<ServableRequest>& servables,
261+ const ServableState::ManagerState goal_state,
262+ std::map<ServableId, ServableState::ManagerState>* const states_reached) {
263+ return WaitUntilServablesReachStateWithTimeout (
264+ servables, goal_state,
265+ /* timeout=*/ absl::InfiniteDuration (), states_reached);
266+ }
267+
258268void ServableStateMonitor::PreHandleEvent (
259269 const EventBus<ServableState>::EventAndTime& state_and_time) {}
260270
0 commit comments