Sha256: 030c3d4b75bda41bd9317c948df42d84e2db5c5234c83661513e5506f7f42e3d

Contents?: true

Size: 418 Bytes

Versions: 2

Compression:

Stored size: 418 Bytes

Contents

module RCelery
  class AsyncResult
    def initialize(task_id)
      @task_id = task_id
      @queue = Task.result_queue(task_id)
    end

    def wait
      result_value = :no_result
      @queue.subscribe do |payload|
        result_value = JSON.parse(payload)['result']
      end

      while(result_value == :no_result)
        sleep(0.05)
      end

      @queue.unsubscribe
      result_value
    end
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
rcelery-1.0.1 lib/rcelery/async_result.rb
rcelery-1.0.0 lib/rcelery/async_result.rb