From 95ff467fca26e53242421a97c29cc3b7821e0341 Mon Sep 17 00:00:00 2001 From: Keunhyun Oh Date: Tue, 3 Dec 2019 23:20:34 +0900 Subject: [PATCH] If any SerialHelper is not generated, calling the commit function makes raising exception because _datapoints is None. It is hard to find the reason of this error. it is because reviewing influxdb-python's code is needed. So, I've fixed that if _datapoints is None in the commit function, _datapoints is set to defaultdict to avoid raising error. --- influxdb/influxdb08/helper.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/influxdb/influxdb08/helper.py b/influxdb/influxdb08/helper.py index f3dec33c..70f720a2 100644 --- a/influxdb/influxdb08/helper.py +++ b/influxdb/influxdb08/helper.py @@ -73,7 +73,7 @@ def __new__(cls, *args, **kwargs): if cls._autocommit and not cls._client: raise AttributeError( 'In {0}, autocommit is set to True, but no client is set.' - .format(cls.__name__)) + .format(cls.__name__)) try: cls._bulk_size = getattr(_meta, 'bulk_size') @@ -128,6 +128,10 @@ def commit(cls, client=None): """ if not client: client = cls._client + + if not cls._datapoints: + cls._datapoints = defaultdict(list) + rtn = client.write_points(cls._json_body_()) cls._reset_() return rtn