Skip to content

Instantly share code, notes, and snippets.

@kanzure
Created July 17, 2015 19:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kanzure/57f1b50cf7fb82cc5c1a to your computer and use it in GitHub Desktop.
Save kanzure/57f1b50cf7fb82cc5c1a to your computer and use it in GitHub Desktop.
Replication of RPC thread hanging using bitcoind v0.10.2.0-g16f4560
# start bitcoind in regtest mode
# ... set the following parameters:
# -rpcthreads=1 -rpctimeout=5
# The behavior can be seen more readily with rpcthreads=1.
bitcoind -regtest -rcpthreads=1 -rpctimeout=5 -debug=1 -logtimestamps=1 -printtoconsole=1 -server=1 -listen=1 -maxconnections=500 -txindex=1
# NOTE: Also, alertnotify and blocknotify scripts are being executed, although
# they don't seem to be necessary to trigger this behavior?
# using python-bitcoinlib in python3.4, although python-bitcoinrpc or even bitcoin-cli might work for this
from bitcoin.core import x, b2x, lx, b2lx
from bitcoin.rpc import Proxy
# connect to bitcoind and send some commands
proxy = Proxy() # or something
# mine some blocks, but don't wait for it to finish mining
bitcoin-cli setgenerate true 1000
# despair... this will hang until bitcoind is done mining.
# Try keyboard interrupting this while it's hanging. If you do not
# keyboardinterrupt it, then the request will be completed eventually
# (although you may have to first proxy = Proxy() while setgenerate
# is running?). However, if you do keyboardinterrupt it, then all
# future rpc requests will fail.
proxy.getinfo()
# also you'll get failures using bitcoin-cli
bitcoin-cli getinfo
# bitcoind v0.10.2.0-g16f4560
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment