From: Richard Conroy Date: 2009-11-13T14:22:12+09:00 Subject: Re: queuing work in a web app (sinatra/webrick) --001517588cfa610093047839d760 Content-Type: text/plain; charset=ISO-8859-1 On Thu, Nov 12, 2009 at 10:45 PM, Gurpal 2000 wrote: > Gurpal 2000 wrote: > > Hi > > > > I want to make a webapp that allows users to queue bit of work > > (converting video for example). They are also able to see the queue at > > any time and check the progress (queued|processing|done) and are able to > > REORDER items in the queue. > > The queue can be stopped (ie. paused) and resumed in between conversions > > of course. > > > > I'm using sintatra and the LoopingThread example from here > > > http://codeidol.com/other/rubyckbk/Multitasking-and-Multithreading/Terminating-a-Thread/ > > > > Im sure there's ppl out there who've done something similar. I can do > > this in java no problem (synchronized lists etc) but not sure how to do > > this in ruby as im sort of a newbie. > > > > I have a working bit of code but im sure im missing something (memory > > leak, synchorizing issues etc). Can post more code (very small) if > > someone's willing to help. > > > > Thanks! > > Oh and i forgot to mention that the queue can be persisted if u want - i > dont care at this stage. But im essentially keeping the queue in a flat > file on disk to hopefully get some 'cheap locking'. I'd like to do this > without a DB so to speak. > > There are numerous solutions for this kind of task: BackgroundJob, DelayedJob, Workling etc. The list is quite extensive. My personal opinion is that spinning off threads to do this work is not the way to go about it. To my mind this is an activity that should be spun off in a separate process. While you want to avoid using the DB for this, I think you should reconsider: DB backed scheduling gets your locking and monitoring via transactions/persistence and it doesn't have to be difficult either. I would look for a background scheduling tool that implicitly uses your DB so that you don't get your hands dirty. --001517588cfa610093047839d760--