Skip to content
This repository was archived by the owner on Oct 29, 2024. It is now read-only.
This repository was archived by the owner on Oct 29, 2024. It is now read-only.

Context manager for InfluxDBClient not working correctly?  #828

Closed
@stdietrich

Description

@stdietrich
  • InfluxDB version: 1.8.0
  • InfluxDB-python version: 5.3.0
  • Python version: 3.6.8
  • Operating system version: CentOS 7 x86_64

With #816 support for context managers has been added to InfluxDBClient. I am currently trying to use it, but it seems not to work:

with influxdb.InfluxDBClient(host='host', port=8086, database='db') as client:
    client.write_points(json_body)

It fails, as client is None:

Traceback (most recent call last):
  File "test.py", line 21, in <module>
    client.write_points(json_body)
AttributeError: 'NoneType' object has no attribute 'write_points'

Looking at the source, the __enter__ function does not return any object, just a pass:

def __enter__(self):
"""Enter function as used by context manager."""
pass

Should this not return the client object, e.g.:

 def __enter__(self): 
     """Enter function as used by context manager.""" 
     return self

Or am I incorrectly using the context manager with influxdb?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions