35

E.g. SidekiqWorker needs to be performed immediately instead of SidekiqWorker.perform_async.

How to perform (execute, run) sidekiq job (worker) synchronously (immediately, now, without a delay)?

Brad Werth
  • 17,411
  • 10
  • 63
  • 88
Sergey Alekseev
  • 11,910
  • 11
  • 38
  • 53
  • Don't agree with the change of Brad Werth. Initially that was http://stackoverflow.com/revisions/25931019/1 where I explained why I added this. But anyway you could downvote or close this if you think it's useless. – Sergey Alekseev Sep 22 '14 at 09:39

1 Answers1

100
SidekiqWorker.new.perform

Voila!

Sergey Alekseev
  • 11,910
  • 11
  • 38
  • 53
  • 2
    Is this somewhere in the docs? I've been unable to find it so far, and need to sync up several jobs for my Cucumber tests. Thanks in advance! – Jack M. Mar 19 '17 at 17:06
  • 1
    @JackM. e.g. https://github.com/mperham/sidekiq/wiki/Testing#testing-workers-directly – Sergey Alekseev Mar 19 '17 at 17:26