Skip to content

Event loops started clashing (recently) #39

@antoniomika

Description

@antoniomika

Not exactly sure why, but event loops started clashing resulting in asyncio to freak out. This is a workaround for that:

index b255b40..a45f001 100644
--- a/test_automation/interactors/alexa/__init__.py
+++ b/test_automation/interactors/alexa/__init__.py
@@ -10,6 +10,8 @@ import time
 import pathlib
 import logging
 import traceback
+import asyncio
+from threading import Thread
 # [ -Third Party ]
 import a_sync
 import blessed
@@ -148,7 +150,14 @@ async def _auth_user_to_avs(*, username, password) -> dict:
 
     # run and block till complete
     logger.info("Running auth server/client...")
-    server_and_client.block()
+
+    def thread_target():
+        return asyncio.new_event_loop().run_until_complete(server_and_client.run())
+
+    thread_1 = Thread(target=thread_target)
+    thread_1.start()
+
+    thread_1.join()
 
     # return the retrieved tokens.
     return auth_server.TOKENS

And here is more info: https://stackoverflow.com/questions/42546099/python-asyncio-migrate-from-3-4-to-3-5

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions