code: def _to_datalibrary_safe(fname, gi, folder_name, sample_info, config):
      
      num_tries = 0
      max_tries = 5
      while 1:
          try:
              _to_datalibrary(fname, gi, folder_name, sample_info, config)
              break
          except (simplejson.scanner.JSONDecodeError, bioblend.galaxy.client.ConnectionError) as e:
              num_tries += 1
              if num_tries > max_tries:
                  raise
              print("Retrying upload, failed with:", str(e))
              time.sleep(5)
docs: Upload with retries for intermittent JSON failures.