Skip to main content

License: GPL v3 PyPI3 PyPI1

RDS

Python Redundant Data Storage Module. Store changes made to a dictionary onto the disk in a redundant manor that will prevent it from getting corrupted if the saving is interrupted.

An RDSDict allows you to make asynchronous and multithreaded modifications to a dictionary safely, and also allows you to have those modifications saved in a way that is redundant. Should the object get interrupted during the saving process, it can restore from the most recently completed entry. An RDSList is the equivalent class for a list.

To create a new instance, each main RDS type takes two required arguments: location and name. location refers to folder where the RDS data will be saved and name refers to the name of the folder where the individual RDS data will be saved for this instance. While location can be shared. name must be unique.

from rds import RDSDict

myDict = RDSDict('C:/RDS/', 'myDict')

Once you have a new main instance, it can be used identically to the type that it is replacing. For example, RDSDict can directly replace a dict in any code, as long as the code does not specifically check if the instance is dict.

Creating a New RDS Type

This module will not be able to detect changes made to an object unless it has a corresponding RDS subtype. As such, if you want to use a custom type in an RDS structure and have changes to it registered, you will need to create your own RDS subtype. Doing so is a relatively simple process. The first thing you must do is create a new class that is a subclass of RDSSubBase.

from rds.rds_subtypes import RDSSubBase

class MyRDSSubType(RDSSubBase):
    def __init__(self, master, instance):
        RDSSubBase.__init__(self, master)
        # Your code here...

You can make the mapping work however you would like, but you should make it so your custom RDS subtype is able to be used identically to the type it will be replacing. Any functions that will be modifying the object should be replaced by one that looks like this:

def myFunction(self, *args, **kwargs):
    id = self._awaitTurn()
    try:
        # This is an example of how you could be calling your functions.
        ret = self.__object.myFunction(*args, **kwargs)
    except:
        # Ensure that you remove the current id from the run list is an error has occured.
        self._running.remove(id)
        raise
    try:
        self._save()
    finally:
        # Ensure that you remove the current id from the run list.
        self._running.remove(id)
    return ret

If you need to do some custom procedure every time you save, you can implement your own save function that does that code before calling self._master._save(). Simply replace any calls to self._master._save() with that function instead.

You must also ensure that your subtype has a getData method that will either return the actual object being used or a copy of it. It is recommended to return a copy in some way so that you can use getData to get a copy of the object that is safe to modify. getData is a method that only takes the self argument.

Once you have done all of that, you will finally need to register your subtype with the module. So for a RDS subtype called MyRDSSubType that will be replacing objects of the class MyClass, you would register that like so:

registerRDSSubType(MyType, MyRDSSubType)

After that line has been executed, the module will be aware of your subtype and automatically replace any instances of the class you specified with the RDS subtype class.

Metadata

Release files for py-rds 1.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-rds 1.3.0
File Size Uploaded Provenance Actions
py-rds-1.3.0.tar.gz 10.3 kB Without provenance Details for py-rds-1.3.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-rds 1.3.0
File Interpreter ABI Platform Actions
py_rds-1.3.0-py3-none-any.whl Python 3 none any Details for py_rds-1.3.0-py3-none-any.whl

Total release size: 36.8 kB

Release files / py-rds-1.3.0.tar.gz

Download URL py-rds-1.3.0.tar.gz
Size 10.3 kB
Tags Source
SHA-256 checksum
How to use checksums
81a551bacae6f0985e3ae3dd7e6203f640038bd1c6cdead596453aaa4330cf25
BLAKE2b-256 checksum
How to use checksums
a7849511be2ccd2a0ae022fcc91cc4600707c95cb248462e7fe423f4a98e637f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.6

Release files / py_rds-1.3.0-py3-none-any.whl

Download URL py_rds-1.3.0-py3-none-any.whl
Size 26.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d4aa2946b4647f373298619e7b483d401c1d43af2740096d7c8dd0499a4dd454
BLAKE2b-256 checksum
How to use checksums
0374257197a90bbd7bce50952cf948205bea54394cecfda030cd93186bd94f26
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.24.0 setuptools/47.3.1 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.6

Security for py-rds 1.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page