diff --git a/pkgs/development/python-modules/aioimaplib/default.nix b/pkgs/development/python-modules/aioimaplib/default.nix index 5d6205362fa5..f26dc63ec141 100644 --- a/pkgs/development/python-modules/aioimaplib/default.nix +++ b/pkgs/development/python-modules/aioimaplib/default.nix @@ -24,6 +24,11 @@ buildPythonPackage rec { hash = "sha256-njzSpKPis033eLoRKXL538ljyMOB43chslio1wodrKU="; }; + patches = [ + # https://github.com/iroco-co/aioimaplib/issues/125 + ./event-loop.patch + ]; + build-system = [ poetry-core ]; nativeCheckInputs = [ diff --git a/pkgs/development/python-modules/aioimaplib/event-loop.patch b/pkgs/development/python-modules/aioimaplib/event-loop.patch new file mode 100644 index 000000000000..616efc6d9001 --- /dev/null +++ b/pkgs/development/python-modules/aioimaplib/event-loop.patch @@ -0,0 +1,25 @@ +diff --git a/aioimaplib/imap_testing_server.py b/aioimaplib/imap_testing_server.py +index b303aa3..419b808 100644 +--- a/aioimaplib/imap_testing_server.py ++++ b/aioimaplib/imap_testing_server.py +@@ -198,12 +198,18 @@ class ImapProtocol(asyncio.Protocol): + DEFAULT_QUOTA = 5000 + + def __init__(self, server_state, fetch_chunk_size=0, capabilities=CAPABILITIES, +- loop=asyncio.get_event_loop()): ++ loop=None): + self.uidvalidity = int(datetime.now().timestamp()) + self.capabilities = capabilities + self.state_to_send = list() + self.delay_seconds = 0 +- self.loop = loop ++ if loop is None: ++ try: ++ self.loop = asyncio.get_running_loop() ++ except RuntimeError: ++ self.loop = asyncio.new_event_loop() ++ else: ++ self.loop = loop + self.fetch_chunk_size = fetch_chunk_size + self.transport = None + self.server_state = server_state \ No newline at end of file