mirror of
https://github.com/projecthorus/sondehub-infra.git
synced 2025-02-07 11:10:16 +00:00
async semaphore fix
This commit is contained in:
parent
67e47ab0fe
commit
9f02d1eece
@ -32,8 +32,6 @@ LAUNCH_ALLOCATE_RANGE_SCALING = 1.5 # Scaling factor - launch allocation range i
|
|||||||
# Do not run predictions if the ascent or descent rate is less than this value
|
# Do not run predictions if the ascent or descent rate is less than this value
|
||||||
ASCENT_RATE_THRESHOLD = 0.5
|
ASCENT_RATE_THRESHOLD = 0.5
|
||||||
|
|
||||||
sem = asyncio.Semaphore(20)
|
|
||||||
|
|
||||||
def flight_profile_by_type(sonde_type):
|
def flight_profile_by_type(sonde_type):
|
||||||
"""
|
"""
|
||||||
Determine the appropriate flight profile based on radiosonde type
|
Determine the appropriate flight profile based on radiosonde type
|
||||||
@ -433,6 +431,7 @@ def predict(event, context):
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
async def predict_async(event, context):
|
async def predict_async(event, context):
|
||||||
|
sem = asyncio.Semaphore(20)
|
||||||
path = "telm-*/_search"
|
path = "telm-*/_search"
|
||||||
payload = {
|
payload = {
|
||||||
"aggs": {
|
"aggs": {
|
||||||
@ -597,7 +596,7 @@ async def predict_async(event, context):
|
|||||||
logging.debug("Start Predict")
|
logging.debug("Start Predict")
|
||||||
jobs=[]
|
jobs=[]
|
||||||
for serial in serials:
|
for serial in serials:
|
||||||
jobs.append(run_predictions_for_serial(serial, serials[serial], reverse_predictions, launch_sites))
|
jobs.append(run_predictions_for_serial(sem, serial, serials[serial], reverse_predictions, launch_sites))
|
||||||
output = await asyncio.gather(*jobs)
|
output = await asyncio.gather(*jobs)
|
||||||
for data in output:
|
for data in output:
|
||||||
if data:
|
if data:
|
||||||
@ -676,7 +675,7 @@ async def predict_async(event, context):
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
async def run_predictions_for_serial(serial, value, reverse_predictions, launch_sites):
|
async def run_predictions_for_serial(sem, serial, value, reverse_predictions, launch_sites):
|
||||||
async with sem:
|
async with sem:
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
#
|
#
|
||||||
|
Loading…
x
Reference in New Issue
Block a user