Giter Site home page Giter Site logo

Thread-safe validation disabling about pyxb HOT 4 CLOSED

pabigot avatar pabigot commented on May 25, 2024
Thread-safe validation disabling

from pyxb.

Comments (4)

pabigot avatar pabigot commented on May 25, 2024

PyXB wasn't designed for use in threaded applications. (Nor was it designed to operate without validation; although it turned out it was possible and useful to some people to disable validation, doing so will change the binding content in ways that may not preserve critical information).

As it turns out, though, the practical (untested) answer is yes, this can be done. Look at pyxb.ValidationConfig, which was designed to control validation behavior on a per-class (XML type/element) basis. If you modify this class to use thread-local state instead of private attributes, you can probably make this work as long as you don't create any new namespaces or change the content models while multiple threads are active.

Interesting use case. I'll consider adding thread-local state to that class in a future release, and look into what it might take to make the rest of the system thread-safe.

from pyxb.

pabigot avatar pabigot commented on May 25, 2024

A candidate solution is 65a3e6d. Let me know if that works for you; if so, and it survives other testing, I'll put it in the next release.

from pyxb.

pabigot avatar pabigot commented on May 25, 2024

On consideration, while 65a3e6d will probably do what you want, it's not really consistent with the pre-existing use of distinct configurations to control validation within the XML space, where changing a validation configuration should affect all threads. It might be possible to make the global configuration thread-local but content-specific ones global, but that could produce some really confusing/non-deterministic behavior.

This gets back to PyXB not being designed for use in a threaded environment. Retro-fitting thread safety is not trivial. At this time I think the final resolution of this issue will be "wontfix" and "don't use PyXB with multiple threads".

from pyxb.

pabigot avatar pabigot commented on May 25, 2024

Based on the fact you can use single-threaded execution as PyXB was designed in your commercial application, I'll just close this as "wontfix".

from pyxb.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.