diff --git a/HISTORY.rst b/HISTORY.rst index f6849ab..a9a7165 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,12 @@ History ======= +v0.10.3 (2021-02-08) +----------------------- + +* Modify async_wrapper to not directly use await within wrapper. + + v0.10.2 (2021-02-08) ----------------------- diff --git a/aioradio/file_ingestion.py b/aioradio/file_ingestion.py index 8c065da..4a29a32 100644 --- a/aioradio/file_ingestion.py +++ b/aioradio/file_ingestion.py @@ -42,14 +42,14 @@ def async_wrapper(func: coroutine) -> Any: """ @functools.wraps(func) - async def wrapper(*args, **kwargs) -> Any: + def wrapper(*args, **kwargs) -> Any: """Decorator wrapper. Returns: Any: any """ - return await func(*args, **kwargs) + return asyncio.get_event_loop().run_until_complete(func(*args, **kwargs)) return wrapper diff --git a/aioradio/tests/file_ingestion_test.py b/aioradio/tests/file_ingestion_test.py index ea4bdf9..5adb01a 100644 --- a/aioradio/tests/file_ingestion_test.py +++ b/aioradio/tests/file_ingestion_test.py @@ -11,7 +11,7 @@ import pytest -from aioradio.file_ingestion import (async_db_wrapper, delete_ftp_file, +from aioradio.file_ingestion import (async_db_wrapper, async_wrapper, delete_ftp_file, establish_ftp_connection, get_current_datetime_from_timestamp, list_ftp_objects, @@ -187,7 +187,22 @@ def test_async_wrapper(user): """Test async_wrapper with database connections.""" if user != 'tim.reichard': - pytest.skip('Skip test_async_wrapper_factory since user is not Tim Reichard') + pytest.skip('Skip test_async_wrapper since user is not Tim Reichard') + + @async_wrapper + async def func(): + return 'Hello World' + + result = func() + assert result == 'Hello World' + + + +def test_async_db_wrapper(user): + """Test async_db_wrapper with database connections.""" + + if user != 'tim.reichard': + pytest.skip('Skip test_async_db_wrapper since user is not Tim Reichard') db_info=[ { diff --git a/setup.py b/setup.py index d9a343f..de94482 100644 --- a/setup.py +++ b/setup.py @@ -7,7 +7,7 @@ long_description = fileobj.read() setup(name='aioradio', - version='0.10.2', + version='0.10.3', description='Generic asynchronous i/o python utilities for AWS services (SQS, S3, DynamoDB, Secrets Manager), Redis, MSSQL (pyodbc), JIRA and more', long_description=long_description, long_description_content_type="text/markdown",