Skip to content

Commit

Permalink
removed support for long deprecated python3.6
Browse files Browse the repository at this point in the history
  • Loading branch information
michgur committed Aug 16, 2023
1 parent 1b1932b commit 6d548c9
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/oneai/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -264,21 +264,16 @@ def __repr__(self) -> str:

# for jupyter environment, to avoid "asyncio.run() cannot be called from a running event loop"
pool = concurrent.futures.ThreadPoolExecutor()
is_36 = sys.version_info[:2] == (3, 6)

if os.name == "nt" and not is_36: # Windows
if os.name == "nt": # Windows
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())


def _async_run_nested(coru):
if is_36:
loop = asyncio.get_event_loop()
return loop.run_until_complete(coru)
else:
try:
asyncio.get_running_loop()
return pool.submit(asyncio.run, coru).result()
except RuntimeError:
pass

return asyncio.run(coru)
try:
asyncio.get_running_loop()
return pool.submit(asyncio.run, coru).result()
except RuntimeError:
pass

return asyncio.run(coru)

0 comments on commit 6d548c9

Please sign in to comment.