Skip to content

TimedStack#pop exception: false #207

@mperham

Description

@mperham

There are times where a timeout in ConnectionPool::TimedStack#pop is an expected result and raising an exception adds unnecessary overhead. Sidekiq uses TimedStack extensively as a blocking primitive so it can sleep for N seconds or be woken up early if the system needs to exit.

https://github.com/sidekiq/sidekiq/blob/67187515db817c7fa77b680d81c8cc48f0fb35ae/lib/sidekiq/scheduled.rb#L117-L120

I propose adding a similiar exception: false option as Ruby's system call, so that #pop will return nil if there was nothing to pop after timeout; this is the happy path for Sidekiq's use case and should cut down on false alarms if there is code in the process monitoring all raised exceptions.

@sleeper.pop(timeout: 30, exception: false)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions