when network is not available, write to pending queues in a background thread