Skip to content

Make _store_schema_list thread safe #1032

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

Conversation

jtilly
Copy link

@jtilly jtilly commented Dec 19, 2022

I'm using jsonschema through altair and as of version 4.17.1 I've been occasionally running into issues when generating plots in parallel (using threading): The commit that broke things for me is 4f8f3, where it makes a difference for me if I'm calling .append(...) in a loop or .extend(...) only once. The reason is that some of my threads end up with an incomplete list of _VOCABULARIES.

I understand that jsonschema is not advertising to be threadsafe (xref #464), but would you still consider merging this patch? I'm imitating the style of _store_schema_list from before 4f8f346.

I should add that my patch doesn't make the function thread safe, just a little bit thread safer.


📚 Documentation preview 📚: https://python-jsonschema--1032.org.readthedocs.build/en/1032/

This makes the function (more) thread safe.
@Julian
Copy link
Member

Julian commented Dec 21, 2022

Hi there! I appreciate you sending this PR -- in general my philosophy is not to merge it because it sets wrong expectations -- I may change this area, again not think about thread-safety, and if it breaks may not feel like merging a future PR, and especially so given it needs tests.

In this specific case though I do know this area is very likely to change by the next release of jsonschema -- specifically the next release will likely make use of entirely different code paths for reference resolution using the referencing library I'm working on, which should improve compliance with the spec whilst making the interfaces better for downstream users.

I'm going to close this for the latter reason more so than the former, since this function is near certain to change or go away, but I'll say if you keep an eye out, it's possible that the way this will look shortly will work already for how you're using it (though yes I still won't really ever promise thread-safety as I personally am a fan of other ways of parallelization). But let's have that conversation again in a few weeks if need be.

@Julian Julian closed this Dec 21, 2022
@jtilly jtilly deleted the make-store-schema-list-thread-safe branch December 21, 2022 15:17
@jtilly
Copy link
Author

jtilly commented Dec 21, 2022

Got it, thank you for the explanation!

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

Successfully merging this pull request may close these issues.

2 participants