del_zk_node.py 417 B

1234567891011121314151617
  1. import time
  2. import sys
  3. from kazoo.client import KazooClient
  4. class ZkClient:
  5. def __init__(self):
  6. self.zk = KazooClient(hosts=sys.argv[1])
  7. self.zk.start()
  8. def del_node(self):
  9. self.zk.delete(sys.argv[2], recursive=True)
  10. print('deleted success')
  11. def __del__(self):
  12. self.zk.stop()
  13. if __name__ == '__main__':
  14. zkclient = ZkClient()
  15. zkclient.del_node()
  16. time.sleep(2)