Modified code to make it more resilient to Redis database disappearing,
and if an error occurs and many measurements need to be stored in master
database, stop publishing those changes to Pachube and Redis