def run(self):
        """Method representing the process’s activity."""
        random.seed(self.seed)
        np.random.seed(self.np_seed)
        if not isinstance(self, multiprocessing.Process):
            # Calling mxnet methods in a subprocess will raise an exception if
            # mxnet is built with GPU support
            # https://github.com/apache/incubator-mxnet/issues/4659
            mx.random.seed(self.mx_seed)

        # Startup - Master waits for this
        try:
            stream_iter = iter(self.stream)
            self._errorq.put(None)
        except Exception as e:  # pylint: disable=broad-except
            tb = traceback.format_exc()
            self._errorq.put((e, tb))

        # Async work
        while True:
            try:  # Check control queue
                c = self._controlq.get(False)
                if c is None:
                    break
                else:
                    raise RuntimeError('Got unexpected control code {}'.format(repr(c)))
            except queue.Empty:
                pass
            except RuntimeError as e:
                tb = traceback.format_exc()
                self._errorq.put((e, tb))
                self._dataq.put(None)

            try:
                data = next(stream_iter)
                error = None
            except Exception as e:  # pylint: disable=broad-except
                tb = traceback.format_exc()
                error = (e, tb)
                data = None
            finally:
                self._errorq.put(error)
                self._dataq.put(data)
def run ( self ) : random . seed ( self . seed ) np . random . seed ( self . np_seed ) if not isinstance ( self , multiprocessing . Process ) : mx . random . seed ( self . mx_seed ) try : stream_iter = iter ( self . stream ) self . _errorq . put ( None ) except Exception as e : tb = traceback . format_exc ( ) self . _errorq . put ( ( e , tb ) ) while True : try : c = self . _controlq . get ( False ) if c is None : break else : raise RuntimeError ( 'Got unexpected control code {}' . format ( repr ( c ) ) ) except queue . Empty : pass except RuntimeError as e : tb = traceback . format_exc ( ) self . _errorq . put ( ( e , tb ) ) self . _dataq . put ( None ) try : data = next ( stream_iter ) error = None except Exception as e : tb = traceback . format_exc ( ) error = ( e , tb ) data = None finally : self . _errorq . put ( error ) self . _dataq . put ( data )
Method representing the process’s activity.