Sidekiq: Is the return value of a worker's `perform` method discarded by Sidekiq?

Created on 28 Jun 2017  路  8Comments  路  Source: mperham/sidekiq

Ruby version:
Sidekiq / Pro / Enterprise version(s):
Sidekiq 4.2.9

Please include your initializer and any error message with the full backtrace.
No error message

Are you using an old version?
No
Have you checked the changelog to see if your issue has been fixed in a later version?
n/a

https://github.com/mperham/sidekiq/blob/master/Changes.md

Is the return value of a perform method when executed by a Sidekiq job discarded? E.g. when called with perform_async?

If my perform method happens to return a large object, could that be an issue anywhere? I'm not interested in the return value, it's being returned as a convenience for testing, when running the worker's perform method inline, not via perform_async. But I'm wondering if it's an issue to return a large value (yes, trying to track down some memory issues)

Most helpful comment

The return value will be GC'd like any other unused data in a Ruby process. Jobs do not have a "result" in Sidekiq and Sidekiq does nothing with the value.

All 8 comments

The return value will be GC'd like any other unused data in a Ruby process. Jobs do not have a "result" in Sidekiq and Sidekiq does nothing with the value.

Is it possible to access this value, @mperham?

In a middleware perhaps?

No, jobs need to explicitly save their result somewhere if they want to access it. Sidekiq does not expose it anywhere.

I've since discovered that it is actually seems possible. The server middleware's yield method returns with it.

Or is it just a coincidence?

That鈥檚 an undocumented implementation detail, not guaranteed to remain in the future if I refactor the code. YMMV 馃榾

Side note:
Where Sidekiq is good is that we can assign a specific queue to a Sidekiq process. Therefore we can fine tune the load of the background server.
We can't do that with Puma for the front end (on Puma worker for a specific controller for example )
This is probably not what Sidekiq is made for (process inline and return) but it would be great (at least for me).

Was this page helpful?
0 / 5 - 0 ratings

Related issues

homanchou picture homanchou  路  3Comments

nikhilm492 picture nikhilm492  路  4Comments

michaeldiscala picture michaeldiscala  路  4Comments

sandstrom picture sandstrom  路  3Comments

bartimaeus picture bartimaeus  路  3Comments