-2

I was trying setting value of backoff_factor in python code using environment variable.

After that i am trying to call backoff_factor from my crateDB code and it is throwing the following error: ValueError: Timeout value connect was backoff_factor, but it must be an int, float or None.

I wanted the retry interval between retries to connect to database.

Please refer below links for the same:

I am setting export 'backoff_factor'=0.1 here: https://github.com/smartsdk/ngsi-timeseries-api/blob/master/setup_dev_env.sh

Using backoff_factor in crate.py file in my source code using os module: https://github.com/smartsdk/ngsi-timeseries-api/blob/dc565af24b303a94f7c298b2567e62487088de3b/src/translators/crate.py#L64

  def setup(self):
        environ.get('backoff_factor')
        url = "{}:{}".format(self.host, self.port)
        self.conn = client.connect([url],'backoff_factor')
        self.cursor = self.conn.cursor()

I also tried upgrading urllib3 and request version but not worked out. Any help will be appreciable.Thanks

metase
  • 1,169
  • 2
  • 16
  • 29
damini chopra
  • 133
  • 2
  • 12

1 Answers1

1

The error message seems clear: backoff_factor must be a number or None and you're passing a string:

  1. environment variables are strings, always, you have to convert them to numbers explicitly, Python rarely performs implicit type conversions.
  2. you're not even passing the backoff_factor you defined to connect here, environ.get() returns the value but you're not assigning it, and then you're passing the literal string 'backoff_factor' to connect.
  3. your use of the API also seems odd, I can't find any backoff_factor parameter in the cratedb documentation but given the style if there were one it'd be a keyword parameter (aka client.connect(url, backoff_factor=...))
Masklinn
  • 34,759
  • 3
  • 38
  • 57