Rob Nielsen
2007-Dec-17 16:47 UTC
[Backgroundrb-devel] Get "some read error" on calls to worker
I''m running the latest from svn (rev 285). I''ve been having a problem launching a process repeatedly. What happens is that I get a debug message "some read error" and then the worker refuses to run again. I''ve stripped my worker down to just doing a puts and it still happens. Like the other threads I want to launch my workers as needed, however I get the same behavior whether use the auto_load and ask_work or use new_worker with no_auto_load. If I remove the job_key I can get it to work, but I still get the "Some read error" message. I need the job to keep one worker per id. I''d rather have separate processes than go the thread route - for now. class UpdateFacebookAccountInfoWorker < BackgrounDRb::MetaWorker set_worker_name :update_facebook_account_info_worker set_no_auto_load true require "facebook_rails_controller_extensions" include RFacebook require ''activemessaging/processor'' include ActiveMessaging::MessageSender def create(args) puts "create=>"+ args.inspect exit! end end and the call... MiddleMan.new_worker( :worker => :update_facebook_account_info_worker, :job_key => @some.id, # Only run one worker per id :data => { :session_key => @session_key, :requesting_fb_id => @organizer.facebook_id, :facebook_ids => @fb_ids, :params => params } ) The output... create=>{:params=>REDACTED]} Some read error Some read error Some read error Thanks Rob -------------- next part -------------- An HTML attachment was scrubbed... URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20071217/a2b14747/attachment-0001.html
hemant kumar
2007-Dec-17 17:14 UTC
[Backgroundrb-devel] Get "some read error" on calls to worker
Hi Rob, On Mon, 2007-12-17 at 11:47 -0500, Rob Nielsen wrote:> I?m running the latest from svn (rev 285). I?ve been having a problem > launching a process repeatedly. What happens is that I get a debug > message ?some read error? and then the worker refuses to run again. > > > > I?ve stripped my worker down to just doing a puts and it still > happens. Like the other threads I want to launch my workers as needed, > however I get the same behavior whether use the auto_load and ask_work > or use new_worker with no_auto_load. If I remove the job_key I can > get it to work, but I still get the ?Some read error? message. I need > the job to keep one worker per id. I?d rather have separate processes > than go the thread route ? for now. > > > > class UpdateFacebookAccountInfoWorker < BackgrounDRb::MetaWorker > > set_worker_name :update_facebook_account_info_worker > > set_no_auto_load true > > > > require "facebook_rails_controller_extensions" > > include RFacebook > > > > require ''activemessaging/processor'' > > include ActiveMessaging::MessageSender > > > > def create(args) > > puts "create=>"+ args.inspect > > exit! > > end > > end > > > > and the call? > > > > MiddleMan.new_worker( > > :worker => :update_facebook_account_info_worker, > > :job_key => @some.id, # Only run one worker per id > > :data => { > > :session_key => @session_key, > > :requesting_fb_id => @organizer.facebook_id, > > :facebook_ids => @fb_ids, > > :params => params > > } > > ) > > > > The output? > > > > create=>{:params=>REDACTED]} > > Some read error > > Some read error > > Some read error > >Ok so, create method is getting invoked when you invoke: MiddleMan.new_worker(...) right? Now, next i see an "exit!" statement there, which basically asks the worker to quit. Now when a worker quits, master process gets an error when reading from that socket, so thats why you are getting "some read error" message. But as far as I can see, create method is getting called alright. Correct me, If i am wrong.>-- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org
Rob Nielsen
2007-Dec-17 17:34 UTC
[Backgroundrb-devel] Get "some read error" on calls to worker
-----Original Message----- From: hemant kumar [mailto:gethemant at gmail.com] Sent: Monday, December 17, 2007 12:14 PM To: Rob Nielsen Cc: backgroundrb-devel at rubyforge.org Subject: Re: [Backgroundrb-devel] Get "some read error" on calls to worker Hi Rob, [SNIP] Ok so, create method is getting invoked when you invoke: MiddleMan.new_worker(...) right? Now, next i see an "exit!" statement there, which basically asks the worker to quit. Now when a worker quits, master process gets an error when reading from that socket, so thats why you are getting "some read error" message. But as far as I can see, create method is getting called alright. Correct me, If i am wrong. ---- Yes it gets called once. Subsequent calls fail for some reason. If I take out the job_key, then I can call it again.
hemant kumar
2007-Dec-17 17:36 UTC
[Backgroundrb-devel] Get "some read error" on calls to worker
On Mon, 2007-12-17 at 12:34 -0500, Rob Nielsen wrote:> > -----Original Message----- > From: hemant kumar [mailto:gethemant at gmail.com] > Sent: Monday, December 17, 2007 12:14 PM > To: Rob Nielsen > Cc: backgroundrb-devel at rubyforge.org > Subject: Re: [Backgroundrb-devel] Get "some read error" on calls to > worker > > Hi Rob, > > > [SNIP] > > Ok so, create method is getting invoked when you invoke: > > MiddleMan.new_worker(...) > > right? > > Now, next i see an "exit!" statement there, which basically asks the > worker to quit. Now when a worker quits, master process gets an error > when reading from that socket, so thats why you are getting "some read > error" message. But as far as I can see, create method is getting called > alright. Correct me, If i am wrong. > > ---- > > Yes it gets called once. Subsequent calls fail for some reason. If I > take out the job_key, then I can call it again.When you can exit! on a worker..its dead, its gone. You can''t access it any more. You shouldn''t call exit! on it, if you want to make further calls to it.>-- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org
Rob Nielsen
2007-Dec-17 17:39 UTC
[Backgroundrb-devel] Get "some read error" on calls to worker
-----Original Message----- From: hemant kumar [mailto:gethemant at gmail.com] Sent: Monday, December 17, 2007 12:36 PM To: Rob Nielsen Cc: backgroundrb-devel at rubyforge.org Subject: RE: [Backgroundrb-devel] Get "some read error" on calls to worker On Mon, 2007-12-17 at 12:34 -0500, Rob Nielsen wrote:> > -----Original Message----- > From: hemant kumar [mailto:gethemant at gmail.com] > Sent: Monday, December 17, 2007 12:14 PM > To: Rob Nielsen > Cc: backgroundrb-devel at rubyforge.org > Subject: Re: [Backgroundrb-devel] Get "some read error" on calls to > worker > > Hi Rob, > > > [SNIP] > > Ok so, create method is getting invoked when you invoke: > > MiddleMan.new_worker(...) > > right? > > Now, next i see an "exit!" statement there, which basically asks the > worker to quit. Now when a worker quits, master process gets an error > when reading from that socket, so thats why you are getting "some read > error" message. But as far as I can see, create method is gettingcalled> alright. Correct me, If i am wrong. > > ---- > > Yes it gets called once. Subsequent calls fail for some reason. If I > take out the job_key, then I can call it again.When you can exit! on a worker..its dead, its gone. You can''t access it any more. You shouldn''t call exit! on it, if you want to make further calls to it. ---- Right. But I''m calling new_worker. So that should start a new instance. Right?>-- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org
hemant kumar
2007-Dec-17 18:08 UTC
[Backgroundrb-devel] Get "some read error" on calls to worker
On Mon, 2007-12-17 at 12:39 -0500, Rob Nielsen wrote:> > -----Original Message----- > From: hemant kumar [mailto:gethemant at gmail.com] > Sent: Monday, December 17, 2007 12:36 PM > To: Rob Nielsen > Cc: backgroundrb-devel at rubyforge.org > Subject: RE: [Backgroundrb-devel] Get "some read error" on calls to > worker > > > On Mon, 2007-12-17 at 12:34 -0500, Rob Nielsen wrote: > > > > -----Original Message----- > > From: hemant kumar [mailto:gethemant at gmail.com] > > Sent: Monday, December 17, 2007 12:14 PM > > To: Rob Nielsen > > Cc: backgroundrb-devel at rubyforge.org > > Subject: Re: [Backgroundrb-devel] Get "some read error" on calls to > > worker > > > > Hi Rob, > > > > > > [SNIP] > > > > Ok so, create method is getting invoked when you invoke: > > > > MiddleMan.new_worker(...) > > > > right? > > > > Now, next i see an "exit!" statement there, which basically asks the > > worker to quit. Now when a worker quits, master process gets an error > > when reading from that socket, so thats why you are getting "some read > > error" message. But as far as I can see, create method is getting > called > > alright. Correct me, If i am wrong. > > > > ---- > > > > Yes it gets called once. Subsequent calls fail for some reason. If I > > take out the job_key, then I can call it again. > > When you can exit! on a worker..its dead, its gone. You can''t access it > any more. You shouldn''t call exit! on it, if you want to make further > calls to it. > > ---- > Right. But I''m calling new_worker. So that should start a new instance. > Right? > > >Ok, sync with latest svn code and see if its fixed. If not then, come to #backgroundrb on freenode. -- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org
hemant kumar
2007-Dec-17 20:09 UTC
[Backgroundrb-devel] Get "some read error" on calls to worker
On Mon, 2007-12-17 at 14:48 -0500, Rob Nielsen wrote:> > -----Original Message----- > From: hemant kumar [mailto:gethemant at gmail.com] > Sent: Monday, December 17, 2007 1:09 PM > To: Rob Nielsen > Cc: backgroundrb-devel at rubyforge.org > Subject: RE: [Backgroundrb-devel] Get "some read error" on calls to > worker > > > On Mon, 2007-12-17 at 12:39 -0500, Rob Nielsen wrote: > > > > -----Original Message----- > > From: hemant kumar [mailto:gethemant at gmail.com] > > Sent: Monday, December 17, 2007 12:36 PM > > To: Rob Nielsen > > Cc: backgroundrb-devel at rubyforge.org > > Subject: RE: [Backgroundrb-devel] Get "some read error" on calls to > > worker > > > > > > On Mon, 2007-12-17 at 12:34 -0500, Rob Nielsen wrote: > > > > > > -----Original Message----- > > > From: hemant kumar [mailto:gethemant at gmail.com] > > > Sent: Monday, December 17, 2007 12:14 PM > > > To: Rob Nielsen > > > Cc: backgroundrb-devel at rubyforge.org > > > Subject: Re: [Backgroundrb-devel] Get "some read error" on calls to > > > worker > > > > > > Hi Rob, > > > > > > > > > [SNIP] > > > > > > Ok so, create method is getting invoked when you invoke: > > > > > > MiddleMan.new_worker(...) > > > > > > right? > > > > > > Now, next i see an "exit!" statement there, which basically asks the > > > worker to quit. Now when a worker quits, master process gets an > error > > > when reading from that socket, so thats why you are getting "some > read > > > error" message. But as far as I can see, create method is getting > > called > > > alright. Correct me, If i am wrong. > > > > > > ---- > > > > > > Yes it gets called once. Subsequent calls fail for some reason. If I > > > take out the job_key, then I can call it again. > > > > When you can exit! on a worker..its dead, its gone. You can''t access > it > > any more. You shouldn''t call exit! on it, if you want to make further > > calls to it. > > > > ---- > > Right. But I''m calling new_worker. So that should start a new > instance. > > Right? > > > > > > > Ok, sync with latest svn code and see if its fixed. If not then, come to > #backgroundrb on freenode. > > ---- > OK that seems to have fixed the issue. Thanks. > > A couple questions: > 1. What happens if you do a new_worker with a given job_key while a > worker with the same key is already running? Does the second task get > queued or does the request simply wait for the first process to finish?Currently none of the above happens. Your request will be simply ignored.> > 2. Does ask_status throw an exception if the worker isn''t running? I > would like to be able to ask if the worker is running before starting > another one.Nope, It won''t throw any exception in user code. It does throw an exception internally. However, you can query status of all workers that are currently running, using MiddleMan.query_all_workers() See, if that output is helpful. -- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org
Rob Nielsen
2007-Dec-17 20:18 UTC
[Backgroundrb-devel] Get "some read error" on calls to worker
-----Original Message----- From: hemant kumar [mailto:gethemant at gmail.com] Sent: Monday, December 17, 2007 3:09 PM To: Rob Nielsen Cc: backgroundrb-devel Subject: RE: [Backgroundrb-devel] Get "some read error" on calls to worker [SNIP]> > 2. Does ask_status throw an exception if the worker isn''t running? I > would like to be able to ask if the worker is running before starting > another one.Nope, It won''t throw any exception in user code. It does throw an exception internally. However, you can query status of all workers that are currently running, using MiddleMan.query_all_workers() See, if that output is helpful. ---- I do get an exception: BackgrounDRb::BdrbConnError when I do the following and the worker is not running. worker_status = MiddleMan.ask_status(:worker => :update_facebook_account_info_worker, :job_key => @id) I don''t mind using a begin rescue block if that is the way to verify that the worker is not running. Is there a better way? P.S. I''m on IRC now but no one seems to be answering (I''m an IRC noob - sorry). -- Let them talk of their oriental summer climes of everlasting conservatories; give me the privilege of making my own summer with my own coals. http://gnufied.org