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

Error running sync command: asyncio.run() cannot be called from a running event loop #14

Open
rickvanoverbeek opened this issue May 4, 2024 · 1 comment

Comments

@rickvanoverbeek
Copy link

linuxserver.io


Expected Behavior

Connect PlextraktSync to Plex and Trakt

Current Behavior

When I run docker exec -it plextraktsync plextraktsync I can connect to Plex. It says Login to MyPlex was Succesful. But after that I get an error: ERROR asyncio.run() cannot be called from a running event loop

Steps to Reproduce

Environment

OS: QNAP NAS
CPU architecture: x86_64
How docker service was installed:
Via Container Station

Command used to create docker container (run/create/compose/screenshot)

Docker logs

[/] # docker exec -it plextraktsync plextraktsync
WARNING plextraktsync without command is deprecated. Executing "plextraktsync
sync"
INFO PlexTraktSync [0.30.2]
Please enter your Plex username or e-mail (): rickvanoverbeek@me.com
Please enter your Plex password:
Enter a 2FA code if enabled, or leave blank otherwise: 037302
╭─ Plex Login ───────────────────╮
│ │
│ Login to MyPlex was successful │
│ │
╰────────────────────────────────╯

ERROR asyncio.run() cannot be called from a running event loop
╭───────────────── Traceback (most recent call last) ─────────────────╮
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/cli.py:26 in │
│ wrap │
│ │
│ 23 │ │ │ cmd = getattr(module, name) │
│ 24 │ │ │ │
│ 25 │ │ │ try: │
│ ❱ 26 │ │ │ │ cmd(*args, **kwargs) │
│ 27 │ │ │ except EOFError as e: │
│ 28 │ │ │ │ raise ClickException(f"Program requested term │
│ connected: {e}") │
│ 29 │ │ │ except ClickException as e: │
│ │
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/decorators/coro. │
│ py:13 in wrapper │
│ │
│ 10 │ """ │
│ 11 │ @wraps(f) │
│ 12 │ def wrapper(*args, **kwargs): │
│ ❱ 13 │ │ return asyncio.run(f(*args, **kwargs)) │
│ 14 │ │
│ 15 │ return wrapper │
│ 16 │
│ │
│ /usr/lib/python3.11/asyncio/runners.py:190 in run │
│ │
│ 187 │ │ │ "asyncio.run() cannot be called from a running ev │
│ 188 │ │
│ 189 │ with Runner(debug=debug) as runner: │
│ ❱ 190 │ │ return runner.run(main) │
│ 191 │
│ 192 │
│ 193 def _cancel_all_tasks(loop): │
│ │
│ /usr/lib/python3.11/asyncio/runners.py:118 in run │
│ │
│ 115 │ │ │
│ 116 │ │ self._interrupt_count = 0 │
│ 117 │ │ try: │
│ ❱ 118 │ │ │ return self._loop.run_until_complete(task) │
│ 119 │ │ except exceptions.CancelledError: │
│ 120 │ │ │ if self._interrupt_count > 0: │
│ 121 │ │ │ │ uncancel = getattr(task, "uncancel", None) │
│ │
│ /usr/lib/python3.11/asyncio/base_events.py:654 in │
│ run_until_complete │
│ │
│ 651 │ │ if not future.done(): │
│ 652 │ │ │ raise RuntimeError('Event loop stopped before Fu │
│ 653 │ │ │
│ ❱ 654 │ │ return future.result() │
│ 655 │ │
│ 656 │ def stop(self): │
│ 657 │ │ """Stop running the event loop. │
│ │
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/commands/sync.py │
│ :48 in sync │
│ │
│ 45 │ │ ) │
│ 46 │ │ config.update(batch_delay=batch_delay) │
│ 47 │ │
│ ❱ 48 │ ensure_login() │
│ 49 │ wc = factory.walk_config.update(movies=movies, shows=shows │
│ 50 │ w = factory.walker │
│ 51 │
│ │
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/commands/login.p │
│ y:10 in ensure_login │
│ │
│ 7 │
│ 8 def ensure_login(): │
│ 9 │ if not factory.has_plex_token: │
│ ❱ 10 │ │ plex_login_autoconfig() │
│ 11 │ │
│ 12 │ if not has_trakt_token(): │
│ 13 │ │ trakt_login_autoconfig() │
│ │
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/commands/plex_lo │
│ gin.py:187 in plex_login_autoconfig │
│ │
│ 184 def plex_login_autoconfig(): │
│ 185 │ username = environ.get("PLEX_USERNAME", CONFIG["PLEX_USER │
│ 186 │ password = environ.get("PLEX_PASSWORD", None) │
│ ❱ 187 │ login(username, password) │
│ 188 │
│ 189 │
│ 190 def plex_login(username, password): │
│ │
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/commands/plex_lo │
│ gin.py:203 in login │
│ │
│ 200 │ print(Panel.fit("Login to MyPlex was successful", title=" │
│ 201 │ │ │ │ │ title_align="left", padding=1, border_sty │
│ 202 │ │
│ ❱ 203 │ (server, plex) = choose_server(account) │
│ 204 │ print(success(f"Connection to {plex.friendlyName} establi │
│ 205 │ │
│ 206 │ token = server.accessToken │
│ │
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/commands/plex_lo │
│ gin.py:163 in choose_server │
│ │
│ 160 def choose_server(account: MyPlexAccount) -> tuple[MyPlexReso │
│ 161 │ while True: │
│ 162 │ │ try: │
│ ❱ 163 │ │ │ server = pick_server(account) │
│ 164 │ │ │ if not server: │
│ 165 │ │ │ │ raise ClickException("Unable to find server f │
│ 166 │
│ │
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/commands/plex_lo │
│ gin.py:150 in pick_server │
│ │
│ 147 │ if len(servers) == 1: │
│ 148 │ │ return servers[0] │
│ 149 │ │
│ ❱ 150 │ server_name = prompt_server(servers) │
│ 151 │ │
│ 152 │ # Sanity check, even the user can't choose invalid resour │
│ 153 │ server = account.resource(server_name) │
│ │
│ /lsiopy/lib/python3.11/site-packages/plextraktsync/commands/plex_lo │
│ gin.py:139 in prompt_server │
│ │
│ 136 │ │ default=None, │
│ 137 │ │ qmark="", │
│ 138 │ │ pointer=">", │
│ ❱ 139 │ ).execute() │
│ 140 │
│ 141 │
│ 142 def pick_server(account: MyPlexAccount) -> MyPlexResource | N │
│ │
│ /lsiopy/lib/python3.11/site-packages/InquirerPy/base/simple.py:330 │
│ in execute │
│ │
│ 327 │ │ Raises: │
│ 328 │ │ │ KeyboardInterrupt: When ctrl-c is pressed and ` │
│ is True. │
│ 329 │ │ """ │
│ ❱ 330 │ │ result = self._run() │
│ 331 │ │ if raise_keyboard_interrupt is not None: │
│ 332 │ │ │ self._raise_kbi = not os.getenv( │
│ 333 │ │ │ │ "INQUIRERPY_NO_RAISE_KBI", not raise_keyboard │
│ │
│ /lsiopy/lib/python3.11/site-packages/InquirerPy/base/complex.py:208 │
│ in _run │
│ │
│ 205 │ │
│ 206 │ def _run(self) -> Any: │
│ 207 │ │ """Run the application.""" │
│ ❱ 208 │ │ return self.application.run() │
│ 209 │ │
│ 210 │ async def _run_async(self) -> None: │
│ 211 │ │ """Run the application asynchronously.""" │
│ │
│ /lsiopy/lib/python3.11/site-packages/prompt_toolkit/application/app │
│ lication.py:1002 in run │
│ │
│ 999 │ │ │
│ 1000 │ │ else: │
│ 1001 │ │ │ # No loop installed. Run like usual. │
│ ❱ 1002 │ │ │ return asyncio.run(coro) │
│ 1003 │ │
│ 1004 │ def _handle_exception( │
│ 1005 │ │ self, loop: AbstractEventLoop, context: dict[str, An │
│ │
│ /usr/lib/python3.11/asyncio/runners.py:186 in run │
│ │
│ 183 │ """ │
│ 184 │ if events._get_running_loop() is not None: │
│ 185 │ │ # fail fast with short traceback │
│ ❱ 186 │ │ raise RuntimeError( │
│ 187 │ │ │ "asyncio.run() cannot be called from a running ev │
│ 188 │ │
│ 189 │ with Runner(debug=debug) as runner: │
╰─────────────────────────────────────────────────────────────────────╯
RuntimeError: asyncio.run() cannot be called from a running event loop
Error: Error running sync command: asyncio.run() cannot be called from a running event loop
sys:1: RuntimeWarning: coroutine 'Application.run_async' was never awaited
RuntimeWarning: Enable tracemalloc to get the object allocation traceback

Copy link

github-actions bot commented May 4, 2024

Thanks for opening your first issue here! Be sure to follow the bug or feature issue templates!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant