Comments (9)
I will make it so it returns a true in case of success.. @obriat
from locust-influxdb-listener.
I think I find the right process by using the ping
method and catching its exception:
influxDBSettings = InfluxDBSettings(
influx_host='influx_host',
influx_port='8086',
user='admin',
pwd='pass',
database='locustidb'
)
for i in range(1, 6):
try:
# start listener with the given configuration
influx = InfluxDBListener(env=environment, influxDbSettings=influxDBSettings)
influx.influxdb_client.ping()
except:
# InfluxDBListener does not throw exception but influx.influxdb_client.ping() do.
wait = i * i
print("Try nĀ°" + str(i) + ": Could not connect to influxdb, wait for " + str(
wait) + " seconds and try again.")
time.sleep(wait) # sleep the script for x seconds and....#
else:
print("Influx (version: " + influx.influxdb_client.ping() + ") is available")
break # ...break out of the loop#
else:
print("Influx is not available!")
from locust-influxdb-listener.
I will take a look.
from locust-influxdb-listener.
@obriat I just uploaded a fix. switched to .error instead of .exception to hide the extra information. https://pypi.org/project/locust-influxdb-listener/0.0.5/
from locust-influxdb-listener.
It didn't fix my issue, I'm a python newbie so maybe my approach is not the right one
I want to wait for influxdb to be ready and just log it if it can't be reach but without stopping my locsut test.
@events.init.add_listener
def locust_init(environment, **kwargs):
...
influxDBSettings = InfluxDBSettings(
influx_host=influx_host,
influx_port='8086',
user='****',
pwd='****',
database='locustidb'
)
# try 5 times for a total of 55s
for i in range(5):
try:
InfluxDBListener(env=environment, influxDbSettings=influxDBSettings)
except:
wait = i * i
log("Try " + i + ": Could not connect to influxdb, wait for" + wait + " seconds and try again.")
time.sleep(wait)
continue
else:
log("Influxdb is available")
break
else:
log("Influxdb is not available")
from locust-influxdb-listener.
@obriat The exception is currently handled by the listener. So you don't have to catch it in your end here.
Make you you update to version 0.0.5, which has the fix for the extra log information....
from locust-influxdb-listener.
You're right, my package wasn't up to date.
I also see my other mistake, I took the logger.exception for a real exception.
So do you know how I can determine if InfluxDBListener is connected ? The object doesn't seem to return any data or state, it just logs the error.
from locust-influxdb-listener.
Here a suggestion: #12.
It turns out that __init__
should not return anything, so I used a state parameter.
from locust-influxdb-listener.
Perfect.
from locust-influxdb-listener.
Related Issues (10)
- test_stop() got an unexpected keyword argument 'environment' HOT 3
- Add python typings HOT 3
- Add Response Code to the collected data HOT 3
- Auto release to pipy once a tag and release is done.
- Some events are not properly defined.
- Thank you. I am making a locust-timestream-listener. HOT 1
- incorrect counting of the number of "total" operations HOT 2
- The example docker stack could be "zero conf" HOT 1
- Duplicated test_stop declaration HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
š Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ššš
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ā¤ļø Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from locust-influxdb-listener.