Added more error handling and reporting
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#!/usr/bin/env python3
|
||||
import json
|
||||
import time
|
||||
from datetime import datetime
|
||||
import tzlocal
|
||||
from xeger import Xeger
|
||||
@@ -92,10 +93,15 @@ class SampleResource(Resource):
|
||||
soundfile.content_type,
|
||||
{'Content-Length': soundfile_content_length})}
|
||||
|
||||
upload_started = time.time()
|
||||
r = requests.post(
|
||||
f"http://{current_app.config.get('STORAGE_HOSTNAME')}/object",
|
||||
files=files
|
||||
)
|
||||
upload_time = time.time() - upload_started
|
||||
|
||||
if upload_time > 0.9:
|
||||
current_app.logger.warning(f"Uploading to storage-service took {upload_time:5} sec")
|
||||
|
||||
if r.status_code not in [200, 201]:
|
||||
return abort(500, f"Failed to upload sample to storage service. Upstream status: {r.status_code}: {r.text}")
|
||||
@@ -104,7 +110,7 @@ class SampleResource(Resource):
|
||||
magic_ampq.publish({'tag': generated_tag})
|
||||
except Exception as e:
|
||||
current_app.logger.exception(e)
|
||||
return abort(569, "AMPQ Publish error")
|
||||
return abort(500, f"AMPQ Publish error: {str(e)}")
|
||||
|
||||
if current_app.config['ENABLE_INFLUXDB']:
|
||||
influx_db.write_points(
|
||||
|
||||
Reference in New Issue
Block a user