Dateien hochladen nach „REST/old“

Lock Object
main
Thomas Hassenstein 2023-06-13 18:48:39 +02:00
parent 48d201f964
commit 673c3f1e39
1 changed files with 14 additions and 14 deletions

View File

@ -52,21 +52,21 @@ def get_random_numbers():
return create_response(432, 'System not ready; try init') return create_response(432, 'System not ready; try init')
with lock: # Sperre (Lock) verwenden, um sicherzustellen, dass nur ein Thread die Methode ausführt with lock: # Sperre (Lock) verwenden, um sicherzustellen, dass nur ein Thread die Methode ausführt
random_numbers = analyze_data(int(quantity), int(bits), startup=False) random_numbers = analyze_data(int(quantity), int(bits), startup=False)
if random_numbers == 400: if random_numbers == 400:
return create_response(500, 'Tests failed, try again') return create_response(543, 'Tests failed, try again')
if random_numbers is False: if random_numbers is False:
return create_response(500, 'Unable to generate random numbers. Restart/Reset System') return create_response(500, 'Unable to generate random numbers. Restart/Reset System')
if random_numbers: if random_numbers:
data = { data = {
'status': 200, 'status': 200,
'description': 'Successful operation; HEX-encoded bit arrays (with leading zeros if required)', 'description': 'Successful operation; HEX-encoded bit arrays (with leading zeros if required)',
'randomNumbers': random_numbers 'randomNumbers': random_numbers
} }
return jsonify(data) return jsonify(data)
else: else:
return create_response(500, 'Unable to generate random numbers.') return create_response(500, 'Unable to generate random numbers.')
@app.route('/trng/randomNum/shutdown', methods=['GET']) @app.route('/trng/randomNum/shutdown', methods=['GET'])
def shutdown_generator(): def shutdown_generator():