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

asyncio event loop error #45

Open
NikosAlexandris opened this issue Nov 10, 2024 · 1 comment
Open

asyncio event loop error #45

NikosAlexandris opened this issue Nov 10, 2024 · 1 comment

Comments

@NikosAlexandris
Copy link

I have a fairly large documentation based on Material for MkDocs (and mkdocs version 1.6.1). I have followed the typical installation and (simplest) configuration instructions as per https://adrienbrignon.github.io/mkdocs-exporter/getting-started/#examples.

I try to serve the documentation, for example via

mkdocs serve --dirty --watch-theme --verbose

yet I get the following error

DEBUG   -  Running `post_build` event from plugin 'exporter-pdf'
Traceback (most recent call last):
  File "/something/something-prototype/.venv/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
             ^^^^^
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
         ^^^^^^^^^^^^^^^^
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/mkdocs/__main__.py", line 272, in serve_command
    serve.serve(**kwargs)
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 85, in serve
    builder(config)
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/mkdocs/commands/serve.py", line 67, in builder
    build(config, serve_url=None if is_clean else serve_url, dirty=is_dirty)
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/mkdocs/commands/build.py", line 347, in build
    config.plugins.on_post_build(config=config)
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/mkdocs/plugins.py", line 602, in on_post_build
    return self.run_event('post_build', config=config)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/mkdocs/plugins.py", line 568, in run_event
    result = method(**kwargs)
             ^^^^^^^^^^^^^^^^
  File "/something/something-prototype/.venv/lib/python3.11/site-packages/mkdocs_exporter/formats/pdf/plugin.py", line 154, in _on_post_build_1
    self.loop.run_until_complete(asyncio.gather(*concurrently(self.tasks, max(1, self.config.concurrency or 1))))
  File "/usr/lib/python3.11/asyncio/base_events.py", line 633, in run_until_complete
    future = tasks.ensure_future(future, loop=self)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 659, in ensure_future
    return _ensure_future(coro_or_future, loop=loop)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/usr/lib/python3.11/asyncio/tasks.py", line 665, in _ensure_future
    raise ValueError('The future belongs to a different loop than '
ValueError: The future belongs to a different loop than the one specified as the loop argument

Else, I got to understand that it is likely required to install playwright with various dependencies for different browsers, etc. I am unsure, however, if this indeed the problem. Since I don't use an apt based package manager, the attempt to

❯ playwright install --with-deps
BEWARE: your OS is not officially supported by Playwright; installing dependencies for ubuntu20.04-x64 as a fallback.
Installing dependencies...
Switching to root user to install dependencies...
[sudo] password for nik:
sh: line 1: apt-get: command not found
Failed to install browsers
Error: Installation process exited with code: 127

Isn't it unusual to exclusively support APT only ?

fails (too).

@nbanyan
Copy link

nbanyan commented Nov 12, 2024

I get a similar error although mine is "attached to a different loop" rather than "belongs to a different loop". In my case setting concurrency to 1 avoids the issue at the cost of much higher compile time.

exporter:
  formats:
    pdf:
      concurrency: 1

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

2 participants