Sidekiq and Mechanize

60 views
Skip to first unread message

CarlM

unread,
May 4, 2017, 12:21:23 PM5/4/17
to Sidekiq

Hi! I would like to use Mechanize inside a worker.


Reading here http://web.archive.org/web/20140521055427/http://rubyforge.org/pipermail/mechanize-users/2009-September/000449.html It seems meachanize is not full thread safe, but using one agent per thread, should work.


Nevetherless i also found this post on Stack overflow http://stackoverflow.com/questions/37799967/sidekiq-mechanize-overwritten-instance The guy was using only instance variables but seems was failing.


Is there any recommended way to use mechanize with sidekiq workers?

Thanks,

Mike Perham

unread,
May 4, 2017, 2:10:36 PM5/4/17
to sid...@googlegroups.com
Hi Carl, relying on a 9 yr old mailing list posting for up-to-date info is probably not a good idea.  Many many Ruby gems have become thread-safe since Sidekiq rose to popularity and mainstream usage.  I don’t know the answers to your questions but please let us know what you learn.

Mike

--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+unsubscribe@googlegroups.com.
To post to this group, send email to sid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sidekiq/a5cad94d-18a2-44e3-8d86-8553b0256147%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Mike Perham – CEO, Contributed Systems
Smart, effective open source infrastructure for your apps.

CarlM

unread,
May 6, 2017, 8:46:36 AM5/6/17
to Sidekiq
I understand that, but the link from stack overflow is from last year, and in fact i saw you also answer there, so I'm not sure if the guy was doing something wrong with the instances variables that i should consider when using mechanize with sidekiq.

I also saw there was another issue talking about mechanize not being thread safe in the github issues (https://github.com/mperham/sidekiq/issues/1946) but there wasn't a real conclusion.

Thanks Mike!


El jueves, 4 de mayo de 2017, 15:10:36 (UTC-3), Mike Perham escribió:
Hi Carl, relying on a 9 yr old mailing list posting for up-to-date info is probably not a good idea.  Many many Ruby gems have become thread-safe since Sidekiq rose to popularity and mainstream usage.  I don’t know the answers to your questions but please let us know what you learn.

Mike
On Thu, May 4, 2017 at 9:21 AM, CarlM <carlos...@gmail.com> wrote:

Hi! I would like to use Mechanize inside a worker.


Reading here http://web.archive.org/web/20140521055427/http://rubyforge.org/pipermail/mechanize-users/2009-September/000449.html It seems meachanize is not full thread safe, but using one agent per thread, should work.


Nevetherless i also found this post on Stack overflow http://stackoverflow.com/questions/37799967/sidekiq-mechanize-overwritten-instance The guy was using only instance variables but seems was failing.


Is there any recommended way to use mechanize with sidekiq workers?

Thanks,

--
You received this message because you are subscribed to the Google Groups "Sidekiq" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+u...@googlegroups.com.

To post to this group, send email to sid...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/sidekiq/a5cad94d-18a2-44e3-8d86-8553b0256147%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Mike Perham

unread,
May 6, 2017, 11:04:49 AM5/6/17
to sid...@googlegroups.com
There is no problem with using instance variables in sidekiq workers.  I dont see why Mechanize wouldn’t be thread-safe, this seems perfectly safe but I don’t know the internals of Mechanize:

def perform(…)
  agent = Mechanize.new
  agent.get(…)
end


To unsubscribe from this group and stop receiving emails from it, send an email to sidekiq+unsubscribe@googlegroups.com.

To post to this group, send email to sid...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages