BackgrounDRb causing freeze and Mongrel timeout

I just installed BackgrounDRb to take care of sending emails to a list
of users and when I try to call the worker, it causes the request to
“freeze” until Mongrel times out.

This is the line that it fails on:

MiddleMan.worker(:invite_worker).send_invite_emails_test(@event.id,
send_to)

The ‘send_to’ parameter is an array of user type (strings) which the
worker will use to filter the list to send the email to. If I remove
this array things work fine. So does this mean I’m limited to
primitive types when I call a worker function?

Here’s the worker code:

def send_invite_emails_test(event_id, send_to)
logger.debug(“Start message…”)
event = Event.find(event_id)

for invite in event.invites
  logger.debug("For invite #{invite.id}")
end

end

The various log files that BackgrounDRb don’t seem to be much help
either. If I call ‘logger.debug’ inside a worker, where does the log
message go?

Any thoughts?

Thanks,
Jeremy

On Sun, Jun 8, 2008 at 1:21 PM, Mozmonkey [email protected]
wrote:

The ‘send_to’ parameter is an array of user type (strings) which the
for invite in event.invites
logger.debug(“For invite #{invite.id}”)
end
end

The various log files that BackgrounDRb don’t seem to be much help
either. If I call ‘logger.debug’ inside a worker, where does the log
message go?

Any thoughts?

I should have told you this earlier, but running git version of
BackgrounDRb is currently the best way to go.

http://gnufied.org/2008/05/21/bleeding-edge-version-of-backgroundrb-for-better-memory-usage/

I upgraded it through Git and it still stalls and times out. Any
other thoughts?

On Sun, 2008-06-08 at 00:51 -0700, Mozmonkey wrote:

worker will use to filter the list to send the email to. If I remove
logger.debug(“For invite #{invite.id}”)
end
end

The various log files that BackgrounDRb don’t seem to be much help
either. If I call ‘logger.debug’ inside a worker, where does the log
message go?

Any thoughts?


my setup backgroundrb logs at log/backgroundrb_11006_debug.log

I don’t think this is the issue but I typically wouldn’t use a name like
‘send_to’ for a variable or a table field just in case of name
collision.

Do you have packet and chronic gems installed?

Have you seen http://backgroundrb.rubyforge.org/

Craig

On Mon, Jun 9, 2008 at 6:19 AM, Mozmonkey [email protected]
wrote:

gems. I’ve also read through their documentation to see if I could
figure out what the problem is – haven’t found anything yet. Until I
get this worked out I have installed Spawn and it seems to work on my
local environment fine. I’m worried how that’ll work in production,
so I’d like to get this figured out if possible.

Well, no worker method will accept two arguments in your code snippet
you are trying exactly the same.
If you want two arguments, i am afraid, you will have to pass them as an
array.

Do you have packet and chronic gems installed?

Have you seenhttp://backgroundrb.rubyforge.org/

Yes, I have been to the main backgroundrb site and followed their
instructions for installation and installed the packet and chronic
gems. I’ve also read through their documentation to see if I could
figure out what the problem is – haven’t found anything yet. Until I
get this worked out I have installed Spawn and it seems to work on my
local environment fine. I’m worried how that’ll work in production,
so I’d like to get this figured out if possible.

Hemant K. wrote:

On Mon, Jun 9, 2008 at 6:19 AM, Mozmonkey [email protected]
wrote:

gems. I’ve also read through their documentation to see if I could
figure out what the problem is – haven’t found anything yet. Until I
get this worked out I have installed Spawn and it seems to work on my
local environment fine. I’m worried how that’ll work in production,
so I’d like to get this figured out if possible.

Well, no worker method will accept two arguments in your code snippet
you are trying exactly the same.
If you want two arguments, i am afraid, you will have to pass them as an
array.

I’m sure this is resolved by now, one way or the other, but i found that
it’s simpler to pass all your arguments inside a single hash, eg

MiddleMan.worker(:invite_worker).send_invite_emails_test(:arg =>
{:event_id => @event.id, :send_to => send_to})

Then pull out at the other end just like a normal hash:

def send_invite_emails_test(arg_hash)
logger.debug(“Start message…”)
event = Event.find(arg_hash[:event_id])
…etc
end

Also, if you send through an active record object (which i know you
aren’t doing), then it will die silently with no logging output
anywhere. That’s my experience anyway. Just mentioning for future
browsers of this thread.

WRT logging, this probably isn’t the smartest answer but the only way i
could do it was to make a new logger inside the worker: eg from one of
mine

class LmailWorker < BackgrounDRb::MetaWorker
set_worker_name :lmail_worker

@@logger = Logger.new(“log/backgroundrb_custom.log”)

def ldb(debug_text)
@@logger.info “### #{caller[0]}: #{debug_text}”
end

def send_mail(arg_hash)
ldb “arg_hash = #{arg_hash.inspect}”
…etc