ianmiell / shutit

Automation framework for programmers
http://ianmiell.github.io/shutit/
MIT License
2.15k stars 110 forks source link

Standalone and background tasks #295

Closed ianmiell closed 7 years ago

ianmiell commented 7 years ago

Now that standalone shutit sessions works, need to create a 'background task' handler that makes these calls asynchronous and well-handled:

>>> import shutit
>>> s1=shutit.create_session()
2017-04-23 12:56:46,116 INFO: Sending: brew list > .shutit_brew_list
2017-04-23 12:56:48,524 INFO: Output (squashed): Ians-MacBook-Air.local:ORIGIN_ENV:iqKnbCRN# 
2017-04-23 12:56:49,373 INFO: Sending: rm -f .shutit_brew_list
2017-04-23 12:56:49,487 INFO: Output (squashed): Ians-MacBook-Air.local:ORIGIN_ENV:iqKnbCRN# 
>>> s1.send('ls')
2017-04-23 12:56:57,491 INFO: Sending: ls
2017-04-23 12:56:57,602 INFO: Output (squashed): Jenkinsfile        README.md       fixterm_src     release.sh      shutit          shutit.py       shutit_assets.pyc   shutit_global.py    shutit_module.pyc   shutit_pexpect.pyc  shutit_skeleton.py   [...]
0

Once that's done, managing multiple nodes with one scripts will be fast and easy.

ianmiell commented 7 years ago

So, running a send in the background means:

ianmiell commented 7 years ago

Branch 295 exists on cage.

ianmiell commented 7 years ago

Need to queue commands to run somehow.

ianmiell commented 7 years ago

send_background function:
    - returns reference to the command object
    - records command in memory in the shutit session
    - boolean for whether to allow other backgrounds in one session (default no)                                                                                                                           
    - there must be a newline (so no nonewline argument)                                                                                                                                                   
    - Object:                                                                                                                                                                                              
        - shutit.background_objects = []                                                                                                                                                                   
        - pid                                                                                                                                                                                              
        - command                                                                                                                                                                                          
        - return value                                                                                                                                                                                     
        - other_background_commands_allowed                                                                                                                                                                
        - timeout?                                                                                                                                                                                         
        - start_time                                                                                                                                                                                       
    - options to:                                                                                                                                                                                          
        - cancel command                                                                                                                                                                                   
        - get status (running, suspended etc)                                                                                                                                                              
        - check_timeout  ```