[Backgroundrb-devel] Cannot invoke ActiveRecord subclass accessors in DRb worker
dorian taylor
dorian.taylor.lists at gmail.com
Thu Jun 15 16:04:25 EDT 2006
argh, forgot to add recipient.
---------- Forwarded message ----------
From: dorian taylor <dorian.taylor.lists at gmail.com>
Date: Jun 15, 2006 1:02 PM
Subject: Re: [Backgroundrb-devel] Cannot invoke ActiveRecord subclass
accessors in DRb worker
To: Ezra Zygmuntowicz <ezmobius at gmail.com>
On 6/15/06, Ezra Zygmuntowicz <ezmobius at gmail.com> wrote:
> Dorian-
>
> Can you show me an example of your worker? You can shave it down to
> just the problem area. I will try to reproduce the problem and get
> back to you with an answer.
Sure, it's as simple as this:
class FoobarWorker
include DRbUndumped
def initialize(options={})
@progress = 0
@logger = BACKGROUNDRB_LOGGER
start_working
end
def start_working(args={})
Thread.new do
@logger.debug "Trying to invoke stuff"
person = Person.find(2)
@logger.debug "First name is #{person.firstname}"
end
end
end
Or the new version:
class FoobarWorker2 < BackgrounDRb::Rails
def do_work (args)
@logger.debug("Attempting to get ActiveRecord instance")
person = Person.find(2)
@logger.debug("First name is #{person.firstname}")
end
end
In both cases, execution stops after (during?) the attempt to find()
the record. I set the ulimit and no core is being dumped. The Rails is
from trunk, and the database is MySQL 5.0 on a Debian/testing system.
> But yeah threads can be hard to debug. But each worker does run in
> it's own thread and I have tested workers that use activerecord
> models by starting a bunch of them at once and they did not block and
> performed as they should. But I am interested to find any problems
> and fix them so please give a concrete example.
I'm sure you did test workers with ActiveRecord as I imagine it would
be a pretty common thing to want to do.
Perhaps it's something with the underlying software then? I'm not
sure. The ActiveRecord instances work fine if I invoke them directly
within a Thread in script/console.
Any insight would be great.
Cheers
Dorian
More information about the Backgroundrb-devel
mailing list