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

Using python-bitshares without writing anything to disk #143

Open
RuneStone0 opened this issue Mar 4, 2020 · 3 comments
Open

Using python-bitshares without writing anything to disk #143

RuneStone0 opened this issue Mar 4, 2020 · 3 comments

Comments

@RuneStone0
Copy link

Background:
I'm running python-bitshares on Google AppEngine, which doesn't allow writes to disk, causing exceptions because python-bitshares attempt to write the sqlite database to disk. This happens, even if BitShares() is initialized with keys: bitshares = BitShares(node=mynode, keys=[mykey])

Root Cause:
This line: self.config = kwargs.get("config_store", SqliteConfigurationStore(**kwargs)) (reference) is executed when a new BitShares() instance is created, resulting in disk writes.

This happens even if config_store is set while creating a new BitShares() instance like below:

from graphenestorage import InRamConfigurationStore
bitshares = BitShares(node=mynode, keys=[mykey], config_store=InRamConfigurationStore())

I suspect that kwargs.get() is causing this issue. For some reason it will call the default value even if another value is parsed to it (in this case SqliteConfigurationStore()). Once SqliteConfigurationStore() is called a folder will be created on disk (reference)

I'm not sure what the best way to fix this, I went with a quick hack:

bitshares = BitShares(node=node, keys=[app.config["WIF"]], config_store="ram") 

and then patched sqlite.py (adding the first line below):

        if kwargs.get("config_store", None) is None:
            if os.path.isdir(data_dir):  # pragma: no cover
                print("checking folder")
                return
            else:  # pragma: no cover
                print("creating folder")
                os.makedirs(data_dir)
@xeroc
Copy link
Owner

xeroc commented Mar 4, 2020

super helpful, thanks!

@RuneStone0
Copy link
Author

Any ETA on this or can I somehow help with this?

@xeroc
Copy link
Owner

xeroc commented Mar 16, 2020

I was looking for a more general solution, however, the way that @Blockchain.inject works, is that it initialized stuff already. Couldn't find an easy approach just yet, sorry.

In the meantime, you may just install your own patch and work with that.

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

No branches or pull requests

2 participants