Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rescue_me

Package Overview
Dependencies
Maintainers
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rescue_me

  • 0.1.3
  • Rubygems
  • Socket score

Version published
Maintainers
1
Created
Source

= rescue_me

Provides a convenience method to retry blocks of code that might fail due to temporary errors, e.g. a network service that becomes temporarily unavailable. The retries are timed to back-off exponentially (2^n seconds), hopefully giving time for the remote server to recover. These are the default wait times between consecutive attempts: 0, 1, 2, 4, 8, 16, 32, 64, 128, ... seconds

Usage: rescue_and_retry(max_attempts, *temporary_exceptions) { # your code }

Example - retry my code up to 7 times (over about a minute) if I see the following 2 network errors: rescue_and_retry(7, Net::SMTPServerBusy, IOError) { smtp.send_message(message, from_address, to_address ) }

Log output: WARN -- : rescue_and_retry(1/5) "SMTPServerBusy: 451 4.3.0 Mail server temporarily rejected message." in ./mailer.rb:43 WARN -- : rescue_and_retry(2/5) "SMTPServerBusy: 451 4.3.0 Mail server temporarily rejected message." in ./mailer.rb:43 WARN -- : rescue_and_retry(3/5) "SMTPServerBusy: 451 4.3.0 Mail server temporarily rejected message." in ./mailer.rb:43

No further output or stacktrace. Block succeeded on 4th attempt.

== Copyright

Copyright (c) 2010 Arild Shirazi. All rights reserved.

See LICENSE for details.

FAQs

Package last updated on 29 Mar 2013

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc