Skip to content

Commit

Permalink
Merge pull request #935 from j0k2r/dev
Browse files Browse the repository at this point in the history
Fix loader functon for async methods
  • Loading branch information
sirosen committed Apr 25, 2024
2 parents d58f864 + 62503be commit 106d5c1
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions src/webargs/core.py
Expand Up @@ -2,6 +2,7 @@

import asyncio
import functools
import inspect
import json
import logging
import typing
Expand Down Expand Up @@ -237,10 +238,12 @@ async def _async_load_location_data(
# an async variant of the _load_location_data method
# the loader function itself may or may not be async
loader_func = self._get_loader(location)
if asyncio.iscoroutinefunction(loader_func):
data = await loader_func(req, schema)
else:
data = loader_func(req, schema)

data = loader_func(req, schema)

if inspect.isawaitable(data):
return await data

return data

def _on_validation_error(
Expand Down

0 comments on commit 106d5c1

Please sign in to comment.