Skip to content

Commit

Permalink
gravelrpc: fd needs to be instanceof FD
Browse files Browse the repository at this point in the history
  • Loading branch information
zielmicha committed Jul 22, 2013
1 parent dcd200e commit 31f8297
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
5 changes: 4 additions & 1 deletion gravelrpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ def _call(self, name, *args, **kwargs):
doc = dict(name=name, args=args, kwargs=kwargs)
if '_fds' in kwargs:
doc['fds'] = kwargs['_fds']
kwargs['_fds'] = None
write_bson(sock, doc)
result = read_bson(sock)
if 'error' in result:
Expand All @@ -77,7 +78,9 @@ def write_bson(sock, doc):

sock.send(struct.pack('!I', len(fds)))
for fd in fds:
passfd.sendfd(sock, fd, 'whatever')
if not isinstance(fd, FD):
raise TypeError('fds need to be instances of FD (not %r)' % fd)
passfd.sendfd(sock, fd.fileno(), 'whatever')

sock.sendall(bson.BSON.encode(doc))
sock.shutdown(socket.SHUT_WR)
Expand Down
1 change: 1 addition & 0 deletions rpctool.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import argparse
import gravelrpc
from gravelrpc import FD

parser = argparse.ArgumentParser()
parser.add_argument('name')
Expand Down
2 changes: 1 addition & 1 deletion testrpc_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
c = gravelrpc.Client('foo')
print c.hello(u'Michał!')

c.say_hello(_fds=[sys.stdout.fileno()])
c.say_hello(_fds=[gravelrpc.FD(1)])

0 comments on commit 31f8297

Please sign in to comment.