Skip to content

Commit

Permalink
Added die() Base method.
Browse files Browse the repository at this point in the history
  • Loading branch information
Adam Lindsay committed May 28, 2009
1 parent 1603182 commit 18cf4fa
Show file tree
Hide file tree
Showing 4 changed files with 69 additions and 0 deletions.
7 changes: 7 additions & 0 deletions gen-py/locator/Base-remote
Expand Up @@ -25,6 +25,7 @@ if len(sys.argv) <= 1 or sys.argv[1] == '--help':
print ' string service_type()'
print ' service_types()'
print ' void debug()'
print ' void die()'
print ''
sys.exit(0)

Expand Down Expand Up @@ -97,4 +98,10 @@ elif cmd == 'debug':
sys.exit(1)
pp.pprint(client.debug())

elif cmd == 'die':
if len(args) != 0:
print 'die requires 0 args'
sys.exit(1)
pp.pprint(client.die())

transport.close()
58 changes: 58 additions & 0 deletions gen-py/locator/Base.py
Expand Up @@ -28,6 +28,9 @@ def service_types(self, ):
def debug(self, ):
pass

def die(self, ):
pass


class Client(Iface):
def __init__(self, iprot, oprot=None):
Expand Down Expand Up @@ -118,6 +121,15 @@ def send_debug(self, ):
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()
def die(self, ):
self.send_die()

def send_die(self, ):
self._oprot.writeMessageBegin('die', TMessageType.CALL, self._seqid)
args = die_args()
args.write(self._oprot)
self._oprot.writeMessageEnd()
self._oprot.trans.flush()

class Processor(Iface, TProcessor):
def __init__(self, handler):
Expand All @@ -127,6 +139,7 @@ def __init__(self, handler):
self._processMap["service_type"] = Processor.process_service_type
self._processMap["service_types"] = Processor.process_service_types
self._processMap["debug"] = Processor.process_debug
self._processMap["die"] = Processor.process_die

def process(self, iprot, oprot):
(name, type, seqid) = iprot.readMessageBegin()
Expand Down Expand Up @@ -183,6 +196,13 @@ def process_debug(self, seqid, iprot, oprot):
self._handler.debug()
return

def process_die(self, seqid, iprot, oprot):
args = die_args()
args.read(iprot)
iprot.readMessageEnd()
self._handler.die()
return


# HELPER FUNCTIONS AND STRUCTURES

Expand Down Expand Up @@ -494,4 +514,42 @@ def __eq__(self, other):
def __ne__(self, other):
return not (self == other)

class die_args(object):

thrift_spec = (
)

def read(self, iprot):
if iprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None and fastbinary is not None:
fastbinary.decode_binary(self, iprot.trans, (self.__class__, self.thrift_spec))
return
iprot.readStructBegin()
while True:
(fname, ftype, fid) = iprot.readFieldBegin()
if ftype == TType.STOP:
break
else:
iprot.skip(ftype)
iprot.readFieldEnd()
iprot.readStructEnd()

def write(self, oprot):
if oprot.__class__ == TBinaryProtocol.TBinaryProtocolAccelerated and self.thrift_spec is not None and fastbinary is not None:
oprot.trans.write(fastbinary.encode_binary(self, (self.__class__, self.thrift_spec)))
return
oprot.writeStructBegin('die_args')
oprot.writeFieldStop()
oprot.writeStructEnd()

def __repr__(self):
L = ['%s=%r' % (key, value)
for key, value in self.__dict__.iteritems()]
return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

def __eq__(self, other):
return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

def __ne__(self, other):
return not (self == other)


3 changes: 3 additions & 0 deletions location.py
Expand Up @@ -180,6 +180,9 @@ def service_types(cls):
def ping(self):
print 'ping()'

def die(self):
raise KeyboardInterrupt


class LocatorHandler(BaseHandler, Locator.Iface):
def __init__(self, peer=None, port=9900):
Expand Down
1 change: 1 addition & 0 deletions locator.thrift
Expand Up @@ -36,6 +36,7 @@ service Base {
string service_type ()
list<string> service_types()
oneway void debug ()
oneway void die ()
}

service Locator extends Base {
Expand Down

0 comments on commit 18cf4fa

Please sign in to comment.