Skip to content

Social plugin does not play well with the i18n plugin in insiders version #6241

Closed

Description

@suricactus

Context

No response

Bug description

We have been using a version 8.x of the mkdocs to build our documentation until yesterday. We decided to upgrade to 9.x and all worked well without the insiders version. When the CI tried to build the docs with the insiders plugin, it failed.

It seems an incompatibility has been introduced with the i18n mkdocs and social mkdocs-material plugin. Seems there is some concurrent computing happening, looking at the final error:

RuntimeError: cannot schedule new futures after shutdown

The site build works fine if I do either of the three:

  • remove all but the English language in plugins.i18n.languages from mkdocs.yml;
  • remove the plugins.social plugin;
  • remove the insiders version of mkdocs-material;

What I have tried is to set some extra logging and reducing the concurrency to just 1, but without success:

  - social:
      # See https://squidfunk.github.io/mkdocs-material/setup/setting-up-social-cards/
      concurrency: 1
      debug: true
      log_level: warn
      cards_color:
        fill: "#72ad2e"
        text: "#FFFFFF"

Related links

Reproduction

I did not add a zip file as I listed the detailed steps to reproduce below.

Steps to reproduce

$ git clone git@github.com:opengisch/QField-docs.git /tmp/qfield-docs && cd /tmp/qfield-docs

$ pip install -r requirements.txt

$ pip freeze | grep mkdocs
mkdocs==1.5.3
mkdocs-material==9.4.6
mkdocs-static-i18n==1.1.1
mkdocs-video==1.5.0

$ mkdocs build &> /dev/null

$ echo $?
0

$ pip install -r requirements-insiders.txt

$ pip freeze | grep mkdocs                                        
mkdocs==1.5.3
mkdocs-material @ git+https://github.com/squidfunk/mkdocs-material-insiders@d566d6c713e43b835808347c10b7bc52ffb603a8
mkdocs-material-extensions==1.3
mkdocs-static-i18n==1.1.1
mkdocs-video==1.5.0

$ mkdocs build &> /dev/null
INFO    -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
             - how-to/itinerary.en.md
INFO    -  mkdocs_static_i18n: Building 'de' documentation to directory: /home/suricactus/work/opengisch/QField-docs/site/de
INFO    -  mkdocs_static_i18n: Overriding 'de' config 'site_name' with 'QField Ökosystem Dokumentation'
INFO    -  The following pages exist in the docs directory, but are not included in the "nav" configuration:
             - how-to/itinerary.en.md
ERROR   -  Error reading page 'index.md': cannot schedule new futures after shutdown
Traceback (most recent call last):
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/bin/mkdocs", line 8, in <module>
    sys.exit(cli())
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
    return self.main(*args, **kwargs)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/click/core.py", line 1078, in main
    rv = self.invoke(ctx)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/click/core.py", line 783, in invoke
    return __callback(*args, **kwargs)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs/__main__.py", line 286, in build_command
    build.build(cfg, dirty=not clean)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs/commands/build.py", line 354, in build
    config.plugins.on_post_build(config=config)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs/plugins.py", line 542, in on_post_build
    return self.run_event('post_build', config=config)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs/plugins.py", line 509, in run_event
    result = method(**kwargs)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs_static_i18n/plugin.py", line 195, in on_post_build
    build(config, dirty=dirty)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs/commands/build.py", line 322, in build
    _populate_page(file.page, config, files, dirty)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs/commands/build.py", line 171, in _populate_page
    page.markdown = config.plugins.on_page_markdown(
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs/plugins.py", line 575, in on_page_markdown
    return self.run_event('page_markdown', markdown, page=page, config=config, files=files)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/mkdocs/plugins.py", line 507, in run_event
    result = method(item, **kwargs)
  File "/home/suricactus/.local/share/virtualenvs/QField-docs-gWjwgoS7/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 177, in on_page_markdown
    self.card_pool_jobs[page.file.src_uri] = self.card_pool.submit(
  File "/home/suricactus/.asdf/installs/python/3.10.13/lib/python3.10/concurrent/futures/thread.py", line 167, in submit
    raise RuntimeError('cannot schedule new futures after shutdown')
RuntimeError: cannot schedule new futures after shutdown

$ echo $?                                                         
1

Browser

No response

Before submitting

Activity

  1. squidfunk commented on Oct 25, 2023

    @squidfunk
    Owner

    Thanks for reporting. Please follow our bug reporting guidelines and attach a minimal reproduction.

  2. added
    needs reproduction
    on Oct 25, 2023
  3. suricactus commented on Oct 26, 2023

    @suricactus
    Author

    Ok, here we go with barebones example with the same problem.
    mkdocs-material-social.zip

    $ pipenv shell
    $ python -m pip install --force-reinstall -r requirements_notworking.txt
    $ python -m mkdocs build                                      
    WARNING -  The "site_url" option is not set. The cards are generated, but not linked, so they won't be visible on social media.
    INFO    -  mkdocs_static_i18n: Building 'en' documentation to directory: /home/suricactus/work/opengisch/issues/mkdocs-material-social/site
    INFO    -  mkdocs_static_i18n: Overriding 'en' config 'site_name' with 'QField Ecosystem Documentation'
    INFO    -  Cleaning site directory
    INFO    -  Building documentation to directory: /home/suricactus/work/opengisch/issues/mkdocs-material-social/site
    WARNING -  The "site_url" option is not set. The cards are generated, but not linked, so they won't be visible on social media.
    INFO    -  mkdocs_static_i18n: Building 'de' documentation to directory: /home/suricactus/work/opengisch/issues/mkdocs-material-social/site/de
    INFO    -  mkdocs_static_i18n: Overriding 'de' config 'site_name' with 'QField Ökosystem Dokumentation'
    ERROR   -  Error reading page 'index.md': cannot schedule new futures after shutdown
    Traceback (most recent call last):
      File "/home/suricactus/.asdf/installs/python/3.10.13/lib/python3.10/runpy.py", line 196, in _run_module_as_main
        return _run_code(code, main_globals, None,
      File "/home/suricactus/.asdf/installs/python/3.10.13/lib/python3.10/runpy.py", line 86, in _run_code
        exec(code, run_globals)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/__main__.py", line 361, in <module>
        cli()
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/click/core.py", line 1157, in __call__
        return self.main(*args, **kwargs)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/click/core.py", line 1078, in main
        rv = self.invoke(ctx)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/click/core.py", line 1688, in invoke
        return _process_result(sub_ctx.command.invoke(sub_ctx))
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/click/core.py", line 1434, in invoke
        return ctx.invoke(self.callback, **ctx.params)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/click/core.py", line 783, in invoke
        return __callback(*args, **kwargs)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/__main__.py", line 286, in build_command
        build.build(cfg, dirty=not clean)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/commands/build.py", line 354, in build
        config.plugins.on_post_build(config=config)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/plugins.py", line 542, in on_post_build
        return self.run_event('post_build', config=config)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/plugins.py", line 509, in run_event
        result = method(**kwargs)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs_static_i18n/plugin.py", line 195, in on_post_build
        build(config, dirty=dirty)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/commands/build.py", line 322, in build
        _populate_page(file.page, config, files, dirty)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/commands/build.py", line 171, in _populate_page
        page.markdown = config.plugins.on_page_markdown(
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/plugins.py", line 575, in on_page_markdown
        return self.run_event('page_markdown', markdown, page=page, config=config, files=files)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/mkdocs/plugins.py", line 507, in run_event
        result = method(item, **kwargs)
      File "/home/suricactus/.local/share/virtualenvs/mkdocs-material-social-xSORQhdE/lib/python3.10/site-packages/material/plugins/social/plugin.py", line 177, in on_page_markdown
        self.card_pool_jobs[page.file.src_uri] = self.card_pool.submit(
      File "/home/suricactus/.asdf/installs/python/3.10.13/lib/python3.10/concurrent/futures/thread.py", line 167, in submit
        raise RuntimeError('cannot schedule new futures after shutdown')
    RuntimeError: cannot schedule new futures after shutdown
    

    If you try the requirements_working.txt it is just fine.

  4. squidfunk commented on Oct 27, 2023

    @squidfunk
    Owner

    Thanks for reporting and providing the reproduction. I think it is safe to move the teardown logic into on_shutdown, which means the thread pool will be available for the entirety of the build. Fixed in 933ea11, which now prints:

    INFO    -  mkdocs_static_i18n: Building 'en' documentation to directory: /Users/squidfunk/Downloads/mkdocs-material-social/site
    INFO    -  mkdocs_static_i18n: Overriding 'en' config 'site_name' with 'QField Ecosystem Documentation'
    INFO    -  Cleaning site directory
    INFO    -  Building documentation to directory: /Users/squidfunk/Downloads/mkdocs-material-social/siteINFO    -  mkdocs_static_i18n: Building 'de' documentation to directory: /Users/squidfunk/Downloads/mkdocs-material-social/site/de
    INFO    -  mkdocs_static_i18n: Overriding 'de' config 'site_name' with 'QField Ökosystem Dokumentation'
    INFO    -  Documentation built in 0.27 seconds
    

    The social cards are now both generated:

    index
    index

  5. added
    bug
    resolved
    and removed
    needs reproduction
    on Oct 27, 2023
  6. squidfunk commented on Oct 27, 2023

    @squidfunk
    Owner

    Released as part of 9.4.7+insiders-4.42.3.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugresolved

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions