Class: RCelery::AsyncResult
- Inherits:
-
Object
- Object
- RCelery::AsyncResult
- Defined in:
- lib/rcelery/async_result.rb
Instance Method Summary collapse
-
#initialize(task_id) ⇒ AsyncResult
constructor
A new instance of AsyncResult.
- #wait ⇒ Object
Constructor Details
#initialize(task_id) ⇒ AsyncResult
Returns a new instance of AsyncResult.
3 4 5 6 |
# File 'lib/rcelery/async_result.rb', line 3 def initialize(task_id) @task_id = task_id @queue = Task.result_queue(task_id) end |
Instance Method Details
#wait ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 |
# File 'lib/rcelery/async_result.rb', line 8 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 |