Skip to content

Commit b171b03

Browse files
joaomariolagopatrickelectric
authored andcommitted
core:services:autopilot_manager: Check async
* Add check for async before calling endpoint to avoid awaiting a non awaitable endpoint function
1 parent a7072e1 commit b171b03

File tree

1 file changed

+6
-1
lines changed
  • core/services/ardupilot_manager/api/v1/routers

1 file changed

+6
-1
lines changed

core/services/ardupilot_manager/api/v1/routers/index.py

+6-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import asyncio
12
import os
23
import shutil
34
from functools import wraps
@@ -31,10 +32,14 @@
3132

3233

3334
def index_to_http_exception(endpoint: Callable[..., Any]) -> Callable[..., Any]:
35+
is_async = asyncio.iscoroutinefunction(endpoint)
36+
3437
@wraps(endpoint)
3538
async def wrapper(*args: Tuple[Any], **kwargs: dict[str, Any]) -> Any:
3639
try:
37-
return await endpoint(*args, **kwargs)
40+
if is_async:
41+
return await endpoint(*args, **kwargs)
42+
return endpoint(*args, **kwargs)
3843
except HTTPException as error:
3944
raise error
4045
except Exception as error:

0 commit comments

Comments
 (0)