Skip to content

Commit 5169b95

Browse files
committed
Do not block event loop when running plugin code
1 parent 5e7dd40 commit 5169b95

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
@@ -1,6 +1,7 @@
11
import asyncio
22
import hashlib
33
import inspect
4+
from functools import partial
45
import json
56
import logging
67
from typing import Any, Callable, Optional
@@ -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)