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

Question: thread safety of execute preprocessor #936

Closed
akhmerov opened this issue Jan 2, 2019 · 7 comments
Closed

Question: thread safety of execute preprocessor #936

akhmerov opened this issue Jan 2, 2019 · 7 comments
Labels

Comments

@akhmerov
Copy link
Member

akhmerov commented Jan 2, 2019

I'd like to execute a bunch of notebooks programmatically using nbconvert. For that I'd like to know if the execute preprocessor is thread-safe (since all the computation is done in an external process (kernel), a ThreadPoolExecutor seems to be a very reasonable solution).

Thanks in advance.

@mgeier
Copy link
Contributor

mgeier commented Jan 2, 2019

It is currently not re-entrant (https://en.wikipedia.org/wiki/Reentrancy_(computing)), see my comment #886 (comment) (somewhere in the middle of the comment, look for "the real problem").

I guess re-entrancy is a requirement for "thread safety" (however you are defining that exactly), so the answer is "no".

Until the problem is fixed, you'll have to use a separate instance of ExecutePreprocessor for each potentially concurrent execution.

@akhmerov
Copy link
Member Author

akhmerov commented Jan 2, 2019

Until the problem is fixed, you'll have to use a separate instance of ExecutePreprocessor for each potentially concurrent execution.

That's my plan anyway: the preprocessors are stateful. Instead I'm wondering about kernel managers and their use of event loops/zmq/anything else that can cause trouble.

@MSeal MSeal added the upstream label May 6, 2019
@MSeal
Copy link
Contributor

MSeal commented May 6, 2019

Late response, but this is mainly blocked for ipython on the upstream issue ipython/ipython#11460

@akhmerov
Copy link
Member Author

akhmerov commented May 6, 2019

Would setting IPython's history to not write on disk be appropriate within nbconvert, or should this really be done on the side of IPython?

@MSeal
Copy link
Contributor

MSeal commented May 6, 2019

We just did a deep dive on making this work at PyCon sprints. I think we have a working prototype. The history change makes ipython work, but there were additional issues on the kernel manager side that needed fixing. I think we'll have this fixed for the next nbconvert patch release.

@MSeal
Copy link
Contributor

MSeal commented Jun 5, 2019

Turns out there's more upstream issues. There will need to be more fixes in ipykernel and jupyter_client (and possibly traitlets) to get this fully fixed. Working slowly on it in my spare time.

@MSeal
Copy link
Contributor

MSeal commented Aug 9, 2019

Should now be resolved with nbconvert 5.6.0 -- see https://discourse.jupyter.org/t/nbconvert-5-6-0-release/1867 for details of the change.

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

No branches or pull requests

3 participants