Esempio n. 1
0
class WallabyClient:
	def __init__(self, host_port_pair, routes, debug=False):
		self.sock = ESock(socket.create_connection(host_port_pair), debug=debug)
		self.connected = True
		self.debug = debug
		self.sync = SyncClient(self.sock, PATH, "w_sync", debug=True)
		routes.update({"w_sync" : self.sync})
		self.routes = routes


	def start(self):
		self.sync.start()
		while 1 and self.connected:
			data = self.sock.recv()
			try:
				if data[1] in self.routes:
					self.routes[data[1]].run(data[0], self)
			except Exception as e:
				if not is_socket_related_error(e):
					capture_trace()
				break


	def stop(self):
		self.sock.close()