Exemple #1
0
    def read_tworld_data(self, dat):
        """Callback from tworld reading handler.
        """
        self.twbuffer.extend(dat)
        while True:
            # This slices a chunk off the buffer and returns it, if a
            # complete chunk is available.
            try:
                ### this unnecessarily de-jsons the message! We only care
                ### about raw, in the common case.
                tup = wcproto.check_buffer(self.twbuffer, namespace=True)
                if not tup:
                    # No more complete messages to pull! (This is the
                    # only return point from this method.)
                    return
            except Exception as ex:
                self.log.warning('Malformed message: %s', ex)
                continue

            try:
                (connid, raw, obj) = tup
                self.handle_tworld_message(connid, raw, obj)
            except Exception as ex:
                self.log.warning('Error handling tworld message', exc_info=True)
            continue
Exemple #2
0
 def twread(self, dat):
     """Callback: invoked when the stream receives new data.
     """
     if not self.twtable:
         return  # must have already closed
     self.twbuffer.extend(dat)
     while True:
         # This slices a chunk off the buffer and returns it, if a
         # complete chunk is available.
         try:
             tup = wcproto.check_buffer(self.twbuffer, namespace=True)
             if not tup:
                 return
             (connid, raw, obj) = tup
             self.twtable.app.queue_command(obj, connid, self.twwcid)
         except Exception as ex:
             self.twtable.log.info('Malformed message: %s', ex)
Exemple #3
0
 def twread(self, dat):
     """Callback: invoked when the stream receives new data.
     """
     if not self.twtable:
         return  # must have already closed
     self.twbuffer.extend(dat)
     while True:
         # This slices a chunk off the buffer and returns it, if a
         # complete chunk is available.
         try:
             tup = wcproto.check_buffer(self.twbuffer, namespace=True)
             if not tup:
                 return
             (connid, raw, obj) = tup
             self.twtable.app.queue_command(obj, connid, self.twwcid)
         except Exception as ex:
             self.twtable.log.info('Malformed message: %s', ex)