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

is client.write() thread safe? #470

Closed
tcloaa opened this issue Jun 19, 2017 · 2 comments
Closed

is client.write() thread safe? #470

tcloaa opened this issue Jun 19, 2017 · 2 comments

Comments

@tcloaa
Copy link

tcloaa commented Jun 19, 2017

Hi, influxdb-python is so awesome.

I would like to ask that, given only 1 client object, is client.write() thread safe?

def write(data):
    client.write(data)

if __name__ == "__main__":
    client = InfluxDBClient('localhost', 8086, 'admin', 'admin', 'db')
    thread.start_new_thread( write, (data1,))
    thread.start_new_thread( write, (data2,) )

or I shall create 2 clients:

def write(data, client):
    client.write(data)

if __name__ == "__main__":
    client1 = InfluxDBClient('localhost', 8086, 'admin', 'admin', 'db')
    client2 = InfluxDBClient('localhost', 8086, 'admin', 'admin', 'db')
    thread.start_new_thread( write, (data1, client1))
    thread.start_new_thread( write, (data2, client2) )

Thanks,

@kernc
Copy link

kernc commented Aug 28, 2017

The client uses requests.Session underneath. psf/requests#1871

@xginn8 xginn8 closed this as completed Oct 3, 2017
@hamedty
Copy link

hamedty commented Jun 14, 2019

Great question with a vague answer.

@tcloaa, does it mean .write is thread safe?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants