Skip to content

Commit

Permalink
hilda_client: Add run_for
Browse files Browse the repository at this point in the history
  • Loading branch information
netanelc305 committed Aug 22, 2024
1 parent f90ee24 commit e457d68
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,8 @@ Here is a gist of methods you can access from `p`:
- Stop process.
- `cont`
- Continue process.
- `run_for`
- Run the process for given interval.
- `detach`
- Detach from process.
Useful in order to exit gracefully so process doesn't get killed
Expand Down
10 changes: 10 additions & 0 deletions hilda/hilda_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,16 @@ def stop(self, *args) -> None:
if not self.process.Stop().Success():
self.log_critical('failed to stop process')

def run_for(self, seconds: float) -> None:
"""
Run the process for a given time
:return:
"""
self.cont()
self.logger.info(f'Running for {seconds} seconds')
time.sleep(seconds)
self.stop()

def cont(self, *args) -> None:
""" Continue process. """
is_running = self.process.GetState() == lldb.eStateRunning
Expand Down

0 comments on commit e457d68

Please sign in to comment.