Skip to content

Commit 50500e5

Browse files
authored
Do not block event loop when running plugin code (#21)
1 parent 5e7dd40 commit 50500e5

File tree

3 files changed

+9
-3
lines changed

3 files changed

+9
-3
lines changed

CHANGELOG.md

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1+
## 0.0.4
2+
3+
### Fixes
4+
5+
* Do not block event loop when running plugin code
6+
17
## 0.0.3
28

39
### Features
410

511
* **OTEL middleware added**
612

7-
813
## 0.0.2
914

1015
### Enhancements
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
__version__ = "0.0.3" # pragma: no cover
1+
__version__ = "0.0.4" # pragma: no cover

unstructured_platform_plugins/etl_uvicorn/api_generator.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import inspect
44
import json
55
import logging
6+
from functools import partial
67
from typing import Any, Callable, Optional
78

89
from fastapi import FastAPI, status
@@ -33,7 +34,7 @@ async def invoke_func(func: Callable, kwargs: Optional[dict[str, Any]] = None) -
3334
if inspect.iscoroutinefunction(func):
3435
return await func(**kwargs)
3536
else:
36-
return func(**kwargs)
37+
return await asyncio.get_event_loop().run_in_executor(None, partial(func, **kwargs))
3738

3839

3940
def check_precheck_func(precheck_func: Callable):

0 commit comments

Comments
 (0)