lazyflow.request.Request

Here are the examples of the python api lazyflow.request.Request taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

2 Examples 7

Example 1

Project: volumina Source File: tiling.py
def submit_to_threadpool(fn, priority):
    if USE_LAZYFLOW_THREADPOOL:
        # Tiling requests are less prioritized than most requests.
        root_priority = [1] + list(priority)
        req = Request(fn, root_priority)
        req.submit()
    else:
        get_render_pool().submit(fn, priority)

Example 2

Project: volumina Source File: exportHelper.py
Function: run
    def run(self, opExport):
        """
        Start the export and return immediately (after showing the progress dialog).
        
        :param opExport: The export object to execute.
                         It must have a 'run_export()' method and a 'progressSignal' member.
        """
        progressDlg = MultiStepProgressDialog(parent=self.parent())
        progressDlg.setNumberOfSteps(1)
        
        def _forwardProgressToGui(progress):
            self._forwardingSignal.emit( partial( progressDlg.setStepProgress, progress ) )
        opExport.progressSignal.subscribe( _forwardProgressToGui )
    
        def _onFinishExport( *args ): # Also called on cancel
            self._forwardingSignal.emit( progressDlg.finishStep )
    
        def _onFail( exc, exc_info ):
            log_exception( logger, "Failed to export layer.", exc_info=exc_info )
            msg = "Failed to export layer due to the following error:\n{}".format( exc )
            self._forwardingSignal.emit( partial(QMessageBox.critical, self.parent(), "Export Failed", msg) )
            self._forwardingSignal.emit( progressDlg.setFailed )

        # Use a request to execute in the background    
        req = Request( opExport.run_export )
        req.notify_cancelled( _onFinishExport )
        req.notify_finished( _onFinishExport )
        req.notify_failed( _onFail )

        # Allow cancel.
        progressDlg.rejected.connect( req.cancel )

        # Start the export
        req.submit()

        # Execute the progress dialog
        # (We can block the thread here because the QDialog spins up its own event loop.)
        progressDlg.exec_()