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

Ablog is NOT safe for parallel read #299

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions roots/test-parallel/conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
extensions = ["ablog"]
7 changes: 7 additions & 0 deletions roots/test-parallel/index.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
test-postlist
===============

.. toctree::
:maxdepth: 1

postlist
4 changes: 4 additions & 0 deletions roots/test-parallel/post1.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. post:: 2020-12-01

post 1
=======
4 changes: 4 additions & 0 deletions roots/test-parallel/post2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. post:: 2020-12-01

post 2
=======
4 changes: 4 additions & 0 deletions roots/test-parallel/post3.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. post:: 2020-12-01

post 3
=======
4 changes: 4 additions & 0 deletions roots/test-parallel/post4.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.. post:: 2020-12-01

post 4
=======
4 changes: 4 additions & 0 deletions roots/test-parallel/postlist.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
postlist
==========

.. postlist::
2 changes: 1 addition & 1 deletion src/ablog/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,6 +167,6 @@ def setup(app):
app.add_message_catalog(MESSAGE_CATALOG_NAME, locale_dir)
return {
"version": __version__,
"parallel_read_safe": True,
"parallel_read_safe": False,
"parallel_write_safe": True,
}
27 changes: 27 additions & 0 deletions src/ablog/tests/test_parallel.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pathlib import Path
from subprocess import run


def test_not_safe_for_parallel_read(rootdir: Path, tmp_path: Path):
"""Ablog is NOT safe for parallel read. In such case, it doesn't collect any posts."""
# https://github.com/sunpy/ablog/issues/297
# Very ugly hack to change the parallel_read_safe value to True
good_read_safe = '"parallel_read_safe": False'
bad_read_safe = '"parallel_read_safe": True'
init_py_path = Path(__file__).parent.parent / "__init__.py"
assert good_read_safe in init_py_path.read_text(encoding="utf-8")
bad_init_py = init_py_path.read_text().replace(good_read_safe, bad_read_safe)
init_py_path.write_text(bad_init_py, encoding="utf-8")

# liborjelinek: I wasn't able to demonstrate the issue with the `parallel` argument to the `sphinx` fixture
# @pytest.mark.sphinx("html", testroot="parallel", parallel=2)
# therefore running sphinx-build externally
indir = rootdir / "test-parallel"
run(["sphinx-build", "-b", "html", indir.as_posix(), tmp_path.as_posix(), "-j", "auto"], check=True)

# And posts are not collected by Ablog...
html = (tmp_path / "postlist.html").read_text(encoding="utf-8")
assert "post 1" not in html
assert "post 2" not in html
assert "post 3" not in html
assert "post 4" not in html
Loading