I have a question concerning where to use the synchronize function. The
point of it is to put all of the code blacks passed to this function in
a queue. This make sure that code gets ran one at a time. This is
required when doing any kind of database activity in backgrondrb and
multiple threads. Otherwise I lose the connection to my database.
So here is my question:
Do I need to do:
@lock = Mutext.new
And do this for EVERY database interaction WITHIN background rb:
#some db activity, like model.save!, model.find, anything that
queries the db
Or do I need to wrap ALL database activity in a sychronize method?
Including various database activity in my controllers that will never be
called by backgroundrb.
Because what if someone makes a request to
somedomain.com/products/create while my backgroundrb script is calling
Product.find_all at the same time? Even though they aren’t both in the
same process would this cause a problem? Or is synchronize ONLY meant
for using in a single process environment where other processes are
Sorry if this is confusing, any help is greatly appreciated.