Skip to content
This repository was archived by the owner on Sep 25, 2019. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 17 additions & 14 deletions lib/coursemology/evaluator/client.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,28 @@ def initialize(one_shot = false)

def run
Signal.trap('SIGTERM', method(:on_sig_term))
loop(&method(:client_loop))
end

loop do
evaluations = allocate_evaluations
private

if evaluations && !evaluations.empty?
on_allocate(evaluations)
else
# :nocov:
# This sleep might not be triggered in the specs, because interruptions to the thread is
# nondeterministically run by the OS scheduler.
sleep(1.minute)
# :nocov:
end
# Performs one iteration of the client loop.
def client_loop
evaluations = allocate_evaluations
if evaluations && !evaluations.empty?
on_allocate(evaluations)
else
raise StopIteration if @terminate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fail instead of raise to signal exceptions.


break if @terminate
# :nocov:
# This sleep might not be triggered in the specs, because interruptions to the thread is
# nondeterministically run by the OS scheduler.
sleep(1.minute)
# :nocov:
end
end

private
raise StopIteration if @terminate

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use fail instead of raise to signal exceptions.

end

# Requests evaluations from the server.
#
Expand Down