[Backgroundrb-devel] Handling exceptions

hemant gethemant at gmail.com
Fri Jun 6 05:00:18 EDT 2008

On Thu, Jun 5, 2008 at 3:27 AM, Aaron Pfeifer <aaron.pfeifer at gmail.com> wrote:
> Is there a convention for handling exceptions within BackgrounDRb workers?
> For example, I have a worker which does some asynchronous data processing
> (*not* a scheduled worker) based on some things in the database.  However,
> if an exception is raised within that worker, then the process for that
> worker is killed off.  Ideally I would want that worker to just silently
> fail and be optimistic that it was an edge case that won't happen every time
> the worker is invoked.
> As of now, I've just added some basic exception handling to log the error
> for future inspection like so:
> class EmailWorker < BackgrounDRb::MetaWorker
>   set_worker_name :email_worker
>   def run(data = nil)
>     do_stuff
>   rescue Exception => ex
>     logger.info ex
>   end
> end
> Is this generally the practice for doing exception handling within workers
> or is there another approach?

Currently, there is no other way, but I think, it would be a good idea
to have a callback ( on_exception :do_this) and continue with things.

More information about the Backgroundrb-devel mailing list