Search code examples
pythonignite

Apache Ignite - simple Python example


I started Apache Ignite node on my local Mac and tried to run Python script to see if it can connect:

import pylibmc
client = pylibmc.Client (["127.0.0.1:11211"], binary=True)
client.set("key", "val")

Got error:

Traceback (most recent call last):
  File "test.py", line 14, in <module>
    client.set("key", "val")
pylibmc.UnknownReadFailure: error 7 from memcached_set: (0x7fd26cc3d8d0) UNKNOWN READ FAILURE,  host: 127.0.0.1:11211 -> libmemcached/response.cc:828

Does anyone know what could be the problem? Or if you have simpler example with step by step to run Apache Ignite with Python, please let me know. (I tried few examples on line and none so far worked)..


Solution

  • To connect to Ignite using a Python client for Memcached, you need to download Ignite and -

    1. Start Ignite cluster with cache configured. For example:

    Shell bin/ignite.sh examples/config/example-cache.xml 2. Connect to Ignite using Memcached client, via binary protocol.

    Python import pylibmc

    client = pylibmc.Client (["127.0.0.1:11211"], binary=True)

    client.set("key", "val")

    print "Value for 'key': %s"%client.get("key")

    from: https://apacheignite.readme.io/docs/memcached-support#python

    Looks like you didn't pass proper config to ignite:

    bin/ignite.sh examples/config/example-cache.xml