Hi,
Sorry for late reply, but second call where you are invoking a method in
worker should be:
geocode_worker = MiddleMan.worker(:geocode_worker,"123")
This should fix your problem.
On Wed, 2008-09-10 at 10:23 -0400, Brent Collier wrote:> I''m having a problem where whenever I try to call a worker method,
> something blows up saying that the worker can''t be found. In
> debugging my code, I can see that the worker was found and that the
> problem doesn''t arrise until I attempt to call a method on it,
async
> or not. My code looks like this:
>
> MiddleMan.new_worker(:worker => :geocode_worker, :worker_key =>
"123")
> sleep(1) # OSX hack!
> geocode_worker = MiddleMan.worker(:geocode_worker, :worker_key =>
> "123")
> geocode_worker.async_geocode_address(:arg => data)
>
>
> Querying the geocode_worker in the debugger, I get:
>
> #<BackgrounDRb::RailsWorkerProxy:0x261c9dc
> @middle_man=#<BackgrounDRb::ClusterConnection:0x2205ad8
> @request_count=2, @bdrb_servers=[#<struct #<Class:0x2205a24>
> ip="127.0.0.1", port=11006>], @round_robin=[0],
@last_polled_time=Wed
> Sep 10 13:58:03 +0000 2008, @disconnected_connections={},
> @backend_connections=[#<BackgrounDRb::Connection:0x22057f4
> @server_ip="127.0.0.1", @connection_status=true, @connection=nil,
> @cluster_conn=#<BackgrounDRb::ClusterConnection:0x2205ad8 ...>,
> @server_port=11006, @mutex=#<Mutex:0x22057cc>>]>,
> @worker_name=:geocode_worker, @tried_connections=[],
> @worker_key={:worker_key=>"123"}>
>
>
> So it would seem that the worker was found, and it has the proper name
> and worker_key. But when I call async_geocode_address on the worker,
> I see this in the backgroundrb log:
>
> Invalid worker with name geocode_worker_worker_key123 and key
> worker_key123
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_connection.rb:52:in
`ask_worker''
>
/Users/brent/near-time/near-time.net-exp-rescue-princexml-5504/vendor/plugins/backgroundrb/server/lib/master_worker.rb:140:in
`method_invoke''
>
/Users/brent/near-time/near-time.net-exp-rescue-princexml-5504/vendor/plugins/backgroundrb/server/lib/master_worker.rb:41:in
`receive_data''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_parser.rb:44:in
`extract''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_parser.rb:26:in
`loop''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_parser.rb:26:in
`extract''
>
/Users/brent/near-time/near-time.net-exp-rescue-princexml-5504/vendor/plugins/backgroundrb/server/lib/master_worker.rb:32:in
`receive_data''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_core.rb:230:in
`read_external_socket''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_core.rb:222:in
`handle_external_messages''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_core.rb:196:in
`handle_read_event''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_core.rb:192:in
`each''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_core.rb:192:in
`handle_read_event''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_core.rb:146:in
`start_reactor''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_core.rb:139:in
`loop''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_core.rb:139:in
`start_reactor''
>
/opt/local/lib/ruby/gems/1.8/gems/packet-0.1.13/lib/packet/packet_master.rb:21:in
`run''
>
/Users/brent/near-time/near-time.net-exp-rescue-princexml-5504/vendor/plugins/backgroundrb/server/lib/master_proxy.rb:14:in
`initialize''
> script/backgroundrb:46:in `new''
> script/backgroundrb:46
>
>
> What''s up with that first line? The worker name and key are both
> totally wrong, and I''m not sure why. Does anybody have any idea
> what''s going on here?
>
> FYI, I''m on the lates Git code as of a couple of days ago and
Packet
> v0.1.13.
>
> -Brent
>
>
>
> --
> Brent Collier | www.BrentCollier.com | www.acts-as-blogr.com
>
> _______________________________________________
> Backgroundrb-devel mailing list
> Backgroundrb-devel at rubyforge.org
> http://rubyforge.org/mailman/listinfo/backgroundrb-devel