Method: flask.app.Flask.ensure_sync
Calls: 555, Exceptions: 0, Paths: 2Back
Path 1: 535 calls (0.96)
View.as_view.
View.as_view.
1def ensure_sync(self, func: t.Callable) -> t.Callable:
2 """Ensure that the function is synchronous for WSGI workers.
3 Plain ``def`` functions are returned as-is. ``async def``
4 functions are wrapped to run and wait for the response.
5
6 Override this method to change how the app runs async views.
7
8 .. versionadded:: 2.0
9 """
10 if iscoroutinefunction(func):
11 return self.async_to_sync(func)
12
13 return func
Path 2: 20 calls (0.04)
_async_app.
AsyncToSync (20)
1def ensure_sync(self, func: t.Callable) -> t.Callable:
2 """Ensure that the function is synchronous for WSGI workers.
3 Plain ``def`` functions are returned as-is. ``async def``
4 functions are wrapped to run and wait for the response.
5
6 Override this method to change how the app runs async views.
7
8 .. versionadded:: 2.0
9 """
10 if iscoroutinefunction(func):
11 return self.async_to_sync(func)
12
13 return func