# Work around for wait with timeout and count\_waiters

**URL:** <https://www.ruby-forum.com/t/work-around-for-wait-with-timeout-and-count-waiters/160083>\
**Category:** Ruby\
**Created:** [February 11, 2009, 5:00pm UTC](https://www.ruby-forum.com/t/work-around-for-wait-with-timeout-and-count-waiters/160083 "2009-02-11T17:00:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![sharat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/7ba0ec/32.png) [@sharat](https://www.ruby-forum.com/u/sharat)\
**Post date:** [February 11, 2009, 5:00pm UTC](https://www.ruby-forum.com/t/work-around-for-wait-with-timeout-and-count-waiters/160083/1 "2009-02-11T17:00:54Z")

</div>

I was using following code in ruby 1.8

```
def self.wait_for_completion_on(signal_data)
  signal_data.lock.synchronize do
    if signal_data.lock.count{|i| !i.nil?} > 0
      signal_data.lock.clear
    else
      k = 0
      while k < SipperConfigurator[:WaitSecondsForTestCompletion]
        signal_data.cond.wait(3)
        break if signal_data.lock.count{|i| !i.nil?} > 0
      end
    end
  end
end

def self.signal_waiting_test(test_name, proxy_call=false)
  signal_data = SIP::Locator[:Tlocks][test_name] if

```

SIP::Locator[:Tlocks]  
unless signal\_data  
return false  
end  
signal\_data.lock.synchronize do  
signal\_data.lock \<\< “signal”  
if signal\_data.cond.count\_waiters \> 0  
signal\_data.cond.signal  
else  
SipLogger[‘siplog::sip\_testcompletionsignalinghelper’].debug  
“Queueing the signal”  
end  
end  
end

But now moving to 1.9, wait with timeout on cond variable and  
count\_waiters is not implemented in montior.rb. What should be the  
workaround?
