lib/asynchronic.rb in asynchronic-0.2.2 vs lib/asynchronic.rb in asynchronic-0.2.3
- old
+ new
@@ -15,18 +15,31 @@
attr_config :default_queue, :asynchronic
attr_config :queue_engine, QueueEngine::InMemory.new
attr_config :data_store, DataStore::InMemory.new
attr_config :logger, Logger.new($stdout)
+ WAITING_TO_RETRY = 30
+
def self.environment
Environment.new queue_engine, data_store
end
def self.[](pid)
environment.load_process pid
end
def self.processes
environment.processes
+ end
+
+ def self.retry_execution(a_class, message)
+ begin
+ result = yield
+ rescue Exception => ex
+ logger.info(a_class) { "Retrying #{message}. ERROR: #{ex.message}" }
+ sleep WAITING_TO_RETRY
+ retry
+ end
+ result
end
end
\ No newline at end of file