Project

General

Profile

« Previous | Next » 

Revision f292535b

Added by Marc Dequènes over 13 years ago

  • ID f292535b6365df76f1edd34bb6aeeb8e6f414614

[fix] ensure ask_to_stop() waits gracefully for conversations to finish while stop() just stopp at once

View differences:

lib/cyborghood/cyborg.rb
def ask_to_stop
logger.info "Bot was asked to stop..."
stop
try_stop
end
def ready_to_stop?
true
end
def stop
logger.info "Bot stopping"
EventMachine.stop
EventMachine.next_tick { EventMachine.stop_event_loop }
end
# core capabilities
......
def schedule_task(callback, &task)
EventMachine.defer(task, callback)
end
protected
def try_stop
if ready_to_stop?
EventMachine.stop_event_loop
else
EventMachine.next_tick { try_stop }
end
end
end
autoload :BotNet, 'cyborghood/cyborg/botnet'

Also available in: Unified diff