def process_pause(processes, timeout): """Pause running processes.""" from aiida.work import RemoteException, DeliveryFailed, TimeoutError, new_blocking_control_panel with new_blocking_control_panel(timeout=timeout) as control_panel: for process in processes: if process.is_terminated: echo.echo_error('Process<{}> is already terminated'.format( process.pk)) continue try: if control_panel.pause_process( process.pk, msg='Paused through `verdi process pause`'): echo.echo_success('paused Process<{}>'.format(process.pk)) else: echo.echo_error('problem pausing Process<{}>'.format( process.pk)) except TimeoutError: echo.echo_error('call to pause Process<{}> timed out'.format( process.pk)) except (RemoteException, DeliveryFailed) as exception: echo.echo_error('failed to pause Process<{}>: {}'.format( process.pk, exception.message))
def work_play(calculations): """ Play paused work calculations """ from aiida.work import RemoteException, DeliveryFailed, new_blocking_control_panel with new_blocking_control_panel() as control_panel: for calculation in calculations: if calculation.is_terminated: echo.echo_error('Calculation<{}> is already terminated'.format( calculation.pk)) continue try: if control_panel.play_process(calculation.pk): echo.echo_success('played Calculation<{}>'.format( calculation.pk)) else: echo.echo_critical( 'problem playing Calculation<{}>'.format( calculation.pk)) except (RemoteException, DeliveryFailed) as exception: echo.echo_critical('failed to play Calculation<{}>: {}'.format( calculation.pk, exception.message))
def process_kill(processes, timeout): """Kill running processes.""" from aiida.work import RemoteException, DeliveryFailed, TimeoutError, new_blocking_control_panel with new_blocking_control_panel(timeout=timeout) as control_panel: for process in processes: if process.is_terminated: echo.echo_error('Process<{}> is already terminated'.format( process.pk)) continue try: if control_panel.kill_process(process.pk): echo.echo_success('killed Process<{}>'.format(process.pk)) else: echo.echo_error('problem killing Process<{}>'.format( process.pk)) except TimeoutError: echo.echo_error('call to kill Process<{}> timed out'.format( process.pk)) except (RemoteException, DeliveryFailed) as exception: echo.echo_error('failed to kill Process<{}>: {}'.format( process.pk, exception.message))