From 4f088b0225e1f31853bb364831f25cef8441b922 Mon Sep 17 00:00:00 2001 From: GuyTeichman <48219633+GuyTeichman@users.noreply.github.com> Date: Tue, 17 Sep 2024 01:57:45 +0300 Subject: [PATCH] changed call location of asyncio.set_event_loop_policy --- rnalysis/gui/main.py | 5 +++-- rnalysis/utils/io.py | 8 +++++--- rnalysis_app.py | 7 +++---- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/rnalysis/gui/main.py b/rnalysis/gui/main.py index 980bee8f..4fa96796 100644 --- a/rnalysis/gui/main.py +++ b/rnalysis/gui/main.py @@ -3,6 +3,9 @@ from multiprocessing import freeze_support from pathlib import Path +if sys.platform == 'win32': + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + import appdirs import nest_asyncio @@ -18,8 +21,6 @@ def main(): freeze_support() - if sys.platform == 'win32': - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) try: asyncio.run(gui.run()) except RuntimeError: diff --git a/rnalysis/utils/io.py b/rnalysis/utils/io.py index ce3bd0fb..aa7be133 100644 --- a/rnalysis/utils/io.py +++ b/rnalysis/utils/io.py @@ -1,4 +1,9 @@ import asyncio +import sys + +if sys.platform == 'win32': + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + import concurrent.futures import contextlib import csv @@ -15,7 +20,6 @@ import shlex import shutil import subprocess -import sys import threading import time import typing @@ -46,8 +50,6 @@ from rnalysis import __version__ from rnalysis.utils import parsing, validation -if sys.platform == 'win32': - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) class RandomExpRetry(Retry): diff --git a/rnalysis_app.py b/rnalysis_app.py index 9bb817dd..51d3b047 100644 --- a/rnalysis_app.py +++ b/rnalysis_app.py @@ -2,12 +2,11 @@ import sys from multiprocessing import freeze_support +if sys.platform == 'win32': + asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) + from rnalysis.gui import gui if __name__ == '__main__': freeze_support() - - if sys.platform == 'win32': - asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy()) - asyncio.run(gui.run())