RestrictedPython | restricted execution environment for Python to run
kandi X-RAY | RestrictedPython Summary
kandi X-RAY | RestrictedPython Summary
A restricted execution environment for Python to run untrusted code.
Support
Quality
Security
License
Reuse
Top functions reviewed by kandi - BETA
- Return astroid Assign node
- Raise an exception
- Add an error node
- Raise an error if node is not allowed
- Return node assignment
- Return an ast_spec for tpl
- Protect a sequence
- Visit a subscript node
- Transform a slice expression
- Return a starred node
- Check function definition
- Return an expression node
- Return list comprehension
- Return node s representation
- Return a comprehension
- Return an ExtSlice node
- Unpacks a sequence
- Return node comprehension
- Handles assignment expressions
- Visit an attribute node
- Modify call node
- Return astroid Name node
- Return a wrapped function that wraps the object
- Visit a class node by returning a fresh instance of it
- Visit the module
- Replace with
RestrictedPython Key Features
RestrictedPython Examples and Code Snippets
Community Discussions
Trending Discussions on RestrictedPython
QUESTION
i'm using restrictedpython in my app in order to allow the "mid-skilled-user" to develop some pieces of additional code to execute as modular on-the-fly add-on.
For some architectural constraints, i have to use a thread pool in order to parallelize the code execution.
Those threads are created by group of 10, then started and wait to be join on the main execution process.
I'm experiencing some weird issues...sometimes, i see that the restrictedpython thread is runned twice!...i've looked around and i'm a bit surprised that no-one was talking about that, i don't know if there is something wrong in my code or if the restrictedpython is not thread safe.
Anyway, you can see that in my RestrictedPythonThread i'm also implementing Mutex lock after compiling the restrictedpython code and then releasing the Mutex lock before i have the compiled code.
Then, the compiled code is executed without any lock using a simple eval.
Here is my code:
...ANSWER
Answered 2021-Mar-20 at 22:20After digging around i've find that using python redis queue the issue went away...so this was definively an issue related to the shared memory space of threads.
Maybe using built-in multiprocess module can be enough, but i haven't tested it because in my application i have already python-rq in use.
Community Discussions, Code Snippets contain sources that include Stack Exchange Network
Vulnerabilities
No vulnerabilities reported
Install RestrictedPython
You can use RestrictedPython like any standard Python library. You will need to make sure that you have a development environment consisting of a Python distribution including header files, a compiler, pip, and git installed. Make sure that your pip, setuptools, and wheel are up to date. When using pip it is generally recommended to install packages in a virtual environment to avoid changes to the system.
Support
Reuse Trending Solutions
Find, review, and download reusable Libraries, Code Snippets, Cloud APIs from over 650 million Knowledge Items
Find more librariesStay Updated
Subscribe to our newsletter for trending solutions and developer bootcamps
Share this Page