def run(self):
        self._create_socket()
        self._running = True
        while self._running:
            if self._pause:
                time.sleep(self.time_to_dead)
            else:
                since_last_heartbeat = 0.0
                request_time = time.time()
                try:
                    #io.rprint('Ping from HB channel') # dbg
                    self.socket.send(b'ping')
                except zmq.ZMQError as e:
                    #io.rprint('*** HB Error:', e) # dbg
                    if e.errno == zmq.EFSM:
                        #io.rprint('sleep...', self.time_to_dead) # dbg
                        time.sleep(self.time_to_dead)
                        self._create_socket()
                    else:
                        raise
                else:
                    while True:
                        try:
                            self.socket.recv(zmq.NOBLOCK)
                        except zmq.ZMQError as e:
                            #io.rprint('*** HB Error 2:', e) # dbg
                            if e.errno == zmq.EAGAIN:
                                before_poll = time.time()
                                until_dead = self.time_to_dead - (before_poll -
                                                                  request_time)

                                # When the return value of poll() is an empty
                                # list, that is when things have gone wrong
                                # (zeromq bug). As long as it is not an empty
                                # list, poll is working correctly even if it
                                # returns quickly. Note: poll timeout is in
                                # milliseconds.
                                if until_dead > 0.0:
                                    while True:
                                        try:
                                            self.poller.poll(1000 * until_dead)
                                        except zmq.ZMQError as e:
                                            if e.errno == errno.EINTR:
                                                continue
                                            else:
                                                raise
                                        else:
                                            break
                            
                                since_last_heartbeat = time.time()-request_time
                                if since_last_heartbeat > self.time_to_dead:
                                    self.call_handlers(since_last_heartbeat)
                                    break
                            else:
                                # FIXME: We should probably log this instead.
                                raise
                        else:
                            until_dead = self.time_to_dead - (time.time() -
                                                              request_time)
                            if until_dead > 0.0:
                                #io.rprint('sleep...', self.time_to_dead) # dbg
                                time.sleep(until_dead)
                            break
Takes body, query and path values from a rest request for testing.
dataset/ETHPy150Open ipython/ipython-py3k/IPython/zmq/kernelmanager.py/HBSocketChannel.run--crossover with--dataset/ETHPy150Open GoogleCloudPlatform/python-compat-runtime/appengine-compat/exported_appengine_sdk/google/appengine/tools/devappserver2/endpoints/endpoints_server_test.py/TransformRequestTests._try_transform_rest_request