Skip to content

Instantly share code, notes, and snippets.

@jbgo
Created June 6, 2011 19:24
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 jbgo/1010888 to your computer and use it in GitHub Desktop.
Save jbgo/1010888 to your computer and use it in GitHub Desktop.
python bert-rpc client and service to demonstrate data being truncated on large responses
import bertrpc
service = bertrpc.Service('localhost', 9999)
def get_data(how_much=100):
return service.request('call').data.lots(how_much)
[{module, data},
{type, external},
{command, "python ./service.py"},
{count, 1}].
from ernie import mod, start
def data_lots(size):
return [{'foo':'bar'} for x in range(size)]
mod('data').fun('lots', data_lots)
if __name__ == '__main__':
start()
~/Desktop/python-libs$ ernie -p 9999 -c ernie.conf -d
erl -boot start_sasl -detached +Bc +K true -smp enable -pz /Users/jordan/.rvm/gems/ree-1.8.7-2010.02/gems/ernie-2.5.2/bin/../ebin \
-ernie_server_app port 9999 -ernie_server_app config '"ernie.conf"' -ernie_server_app log_level 2 -run ernie_server_app boot
~/Desktop/python-libs$ python -i client.py
>>> r = get_data(100)
>>> r[0]
{'foo': 'bar'}
>>> r[99]
{'foo': 'bar'}
>>> len(r)
100
>>> r = get_data(100000)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "client.py", line 9, in get_data
return service.request('call').data.lots(how_much)
File "build/bdist.macosx-10.6-universal/egg/bertrpc/client.py", line 50, in callable
File "build/bdist.macosx-10.6-universal/egg/bertrpc/client.py", line 58, in method_missing
File "build/bdist.macosx-10.6-universal/egg/bertrpc/client.py", line 76, in execute
File "build/bdist.macosx-10.6-universal/egg/bertrpc/client.py", line 118, in decode
File "build/bdist.macosx-10.6-universal/egg/bert/__init__.py", line 13, in decode
File "build/bdist.macosx-10.6-universal/egg/bert/codec.py", line 30, in decode
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 28, in decode
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 68, in decode_h
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 106, in decode_l
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 68, in decode_h
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 106, in decode_l
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 68, in decode_h
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 116, in decode_m
struct.error: unpack requires a string argument of length 4
>>> r = get_data(1000000) # warning, this takes awhile (~1 min) to run
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "client.py", line 9, in get_data
return service.request('call').data.lots(how_much)
File "build/bdist.macosx-10.6-universal/egg/bertrpc/client.py", line 50, in callable
File "build/bdist.macosx-10.6-universal/egg/bertrpc/client.py", line 58, in method_missing
File "build/bdist.macosx-10.6-universal/egg/bertrpc/client.py", line 76, in execute
File "build/bdist.macosx-10.6-universal/egg/bertrpc/client.py", line 118, in decode
File "build/bdist.macosx-10.6-universal/egg/bert/__init__.py", line 13, in decode
File "build/bdist.macosx-10.6-universal/egg/bert/codec.py", line 30, in decode
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 28, in decode
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 68, in decode_h
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 106, in decode_l
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 68, in decode_h
File "build/bdist.macosx-10.6-universal/egg/erlastic/codec.py", line 31, in decode_part
IndexError: string index out of range
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment