Hello!
I am desperately trying to get a Python3.5.2 native
interface to the ETCD V3 Api (since there is no new library currently in
place or supported).
I nstalled the newest Protoc Compiler as
well as the current GRPC tools straight from the source, gathered up all
the proto-files which are imported in the
etcd/etcdserver/etcdserverpb/rpc.proto from various sources and let it
generate a grpc python file for each of them. I put them all into one
folder, fixed up the imports to match and then fired up Ipython to try
some things in the console.
At the very least the KV store seemed
to work great. Put and Range were working fine and I was sure that
everything else would work out as well.
But when I tried to set up a Watch, the Thread spawned in the background immediately dies. Here is my console output:
In [1]: import etcd_grpc.rpc_pb2 as rpc
In [2]: import grpc
In [3]: chan= grpc.insecure_channel('localhost:2379')
In [4]: kv = rpc.KVStub(chan)
In [5]: put = kv.Put(rpc.PutRequest(key=b'lala', value=b'hoho'))
In [6]: put
Out[6]:
header {
cluster_id: 14841639068965178418
member_id: 10276657743932975437
revision: 15
raft_term: 3
}
In [7]: wcr = rpc.WatchCreateRequest(key=b'bam')
In [8]: wr = rpc.WatchRequest(create_request=wcr)
In [9]: wi = rpc.WatchStub(grpc.insecure_channel('localhost:2379'))
In [10]: watch = wi.Watch(wr)
In [11]: Exception in thread Thread-849:
Traceback (most recent call last):
File "/usr/lib/python3.5/threading.py", line 914, in _bootstrap_inner
self.run()
File "/usr/lib/python3.5/threading.py", line 862, in run
self._target(*self._args, **self._kwargs)
File "/usr/local/lib/python3.5/dist-packages/grpc/_channel.py", line 184, in consume_request_iterator
for request in request_iterator:
TypeError: 'WatchRequest' object is not iterable
The
thread supposed to feed the watch-Rendevouz died leaving the console in
an eternal loop (or maybe there is a long timeout) if I try to use
watch.next()
I tried debugging it, but the automatedly generated
code is stacked so deep and on top there is the threading complexity....
i have no idea what the final function does and why it would try to
treat the WatchRequest as an iterator. I haven't modified the output of
the grpc tools at all.
If someone has an Idea, could help me with
this, or even has a working ETCD V3 Interface for python laying around.
I would be grateful for either.
Thank you,
Martin Znamirowski