Revision 32d2114b
Added by Marc Dequènes over 14 years ago
- ID 32d2114b330431f458eea50f6837dcef5e88271c
bin/postman | ||
---|---|---|
|
||
@current_thread = Thread.current
|
||
@stop_asap = false
|
||
@waiting = false
|
||
|
||
logger.info "Bot '#{self.human_name}' loaded"
|
||
end
|
||
... | ... | |
sleep_time = @config.imap.min_check_interval - (t2 - t)
|
||
if sleep_time > 0
|
||
logger.debug "Having a break before new check..."
|
||
@waiting = true
|
||
begin
|
||
sleep(sleep_time)
|
||
rescue
|
||
end
|
||
@waiting = false
|
||
end
|
||
end
|
||
logger.info "Bot was asked to stop..." if @stop_asap
|
||
... | ... | |
|
||
def ask_to_stop
|
||
@stop_asap = true
|
||
Thread.critical = true
|
||
@current_thread.raise if @waiting
|
||
Thread.critical = false
|
||
# wakeup sleeps
|
||
Process.kill("ALRM", $$)
|
||
end
|
||
|
||
private
|
Also available in: Unified diff
[fix] handle program stop better