Skip to content

Commit

Permalink
Modify async_wrapper to not directly use await
Browse files Browse the repository at this point in the history
  • Loading branch information
tim.reichard committed Feb 8, 2021
1 parent 4e0548c commit 634f409
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 5 deletions.
6 changes: 6 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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)
-----------------------

Expand Down
4 changes: 2 additions & 2 deletions aioradio/file_ingestion.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
19 changes: 17 additions & 2 deletions aioradio/tests/file_ingestion_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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=[
{
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down

0 comments on commit 634f409

Please sign in to comment.