Exemple #1
0
 def _read_next_message(self):
     # Return a new incoming message using a generator.
     # Not guaranteed to be a unique instance. Should copy if needed.
     msg = MatlabRPC()
     with open(self.filename, 'rb') as f:
         while _read_next(f, msg):
             yield msg
Exemple #2
0
 def _read_next_message(self):
     # Returns a new incoming message using a generator.
     while not self._done:
         f = self._get_file()
         while not self._done:
             msg = MatlabRPC()
             status = _read_next(f, msg)
             if status == _READ_GOOD:
                 yield msg
             elif status == _READ_END:
                 break
         # Close the file if we reach the end, NOT when exiting the scope
         # (which is why `with` is not used here).
         # This way the user can read a few messages at a time, with the
         # same file handle.
         # @note We must close / reopen the file when looping because the
         # C++ program will effectively send a EOF signal when it closes
         # the pipe.
         self._close_file()
         if not self._loop:
             break