Skip to content

Commit

Permalink
fix(pre-commit,plugin): 更新check-jsonschema版本和调整Windows事件循环策略
Browse files Browse the repository at this point in the history
- 更新check-jsonschema版本至0.29.2,提升CI流程的可靠性。
- 在NbConvertPlugin中,针对Windows平台设置WindowsSelectorEventLoopPolicy,以解决Proactor事件循环不支持add_reader方法的问题。
  • Loading branch information
Liu Xue Yan committed Aug 27, 2024
1 parent 01d152e commit c048733
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ repos:
- id: nbstripout

- repo: https://github.com/python-jsonschema/check-jsonschema
rev: "0.28.6"
rev: "0.29.2"
hooks:
- id: check-github-workflows
- id: check-readthedocs
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# The file defines requirements for the project's local development.
# It's NOT package install dependencies.

-e .

# material theme and markdown extensions
mkdocs-material
pymdown-extensions
Expand Down
10 changes: 7 additions & 3 deletions src/mkdocs_nbconvert/plugin.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import asyncio
import platform
import sys
from glob import iglob
from os import makedirs, path, remove, removedirs
from pprint import pformat
Expand Down Expand Up @@ -55,12 +55,16 @@ def on_files(self, files, config, **kwargs):
_opts = self.config.get("execute_options") or {}
exe_opts = {k: v for k, v in _opts.items() if k in ("timeout", "kernel_name") and v is not None}
exe_path, exe_save, exe_exit_on_error = (_opts.get(a) for a in ("run_path", "write_back", "exit_on_error"))

# On windows:
# Proactor event loop does not implement add_reader family of methods required for zmq.
# Registering an additional selector thread for add_reader support via tornado.
# Use `asyncio.set_event_loop_policy(WindowsSelectorEventLoopPolicy())` to avoid this warning.
if platform.system() == "Windows":
asyncio.set_event_loop_policy(asyncio.WindowsSelectorEventLoopPolicy())
if sys.platform == "win32":
from asyncio import windows_events

asyncio.set_event_loop_policy(windows_events.WindowsSelectorEventLoopPolicy())

# Converting
for i, nb_path in enumerate(nb_finder, 1):
# Prepare output file/dir
Expand Down

0 comments on commit c048733

Please sign in to comment.