Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: update for minimum of Python 3.7 #1509

Merged
merged 1 commit into from Mar 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion setup.py
Expand Up @@ -106,7 +106,7 @@
"Intended Audience :: Science/Research",
"License :: OSI Approved :: MIT License",
"Natural Language :: English",
"Programming Language :: Python :: 3.5",
"Programming Language :: Python :: 3.7",
"Topic :: Scientific/Engineering :: Bio-Informatics",
],
)
39 changes: 14 additions & 25 deletions snakemake/common/__init__.py
Expand Up @@ -21,7 +21,7 @@
del get_versions


MIN_PY_VERSION = (3, 5)
MIN_PY_VERSION = (3, 7)
DYNAMIC_FILL = "__snakemake_dynamic__"
SNAKEMAKE_SEARCHPATH = str(Path(__file__).parent.parent.parent)
UUID_NAMESPACE = uuid.uuid5(uuid.NAMESPACE_URL, "https://snakemake.readthedocs.io")
Expand All @@ -32,30 +32,19 @@
ON_WINDOWS = platform.system() == "Windows"


if sys.version_info < (3, 7):

def async_run(coroutine):
loop = asyncio.get_event_loop()
return loop.run_until_complete(coroutine)

else:

def async_run(coroutine):
"""Attaches to running event loop or creates a new one to execute a
coroutine.

.. seealso::

https://github.com/snakemake/snakemake/issues/1105
https://stackoverflow.com/a/65696398

"""
try:
_ = asyncio.get_running_loop()
except RuntimeError:
asyncio.run(coroutine)
else:
asyncio.create_task(coroutine)
def async_run(coroutine):
"""Attaches to running event loop or creates a new one to execute a
coroutine.
.. seealso::
https://github.com/snakemake/snakemake/issues/1105
https://stackoverflow.com/a/65696398
"""
try:
_ = asyncio.get_running_loop()
except RuntimeError:
asyncio.run(coroutine)
else:
asyncio.create_task(coroutine)


# A string that prints as TBD
Expand Down
5 changes: 1 addition & 4 deletions tests/testapi.py
Expand Up @@ -53,10 +53,7 @@ async def main():
async_run(dummy_task())
test_run_script_directive()

if sys.version_info < (3, 7):
async_run(main())
else:
asyncio.run(main())
asyncio.run(main())


def test_dicts_in_config():
Expand Down