Extend job types
executor.engine.job.extend.SubprocessJob(cmd, record_cmd=True, base_class=ThreadJob, callback=None, error_callback=None, retries=0, retry_time_delta=0.0, name=None, condition=None, wait_time_delta=0.01, redirect_out_err=False, target_dir='$current_dir', popen_kwargs=None, **attrs)
Create a job that runs a subprocess.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cmd
|
str
|
The command to run. |
required |
record_cmd
|
bool
|
Whether to record the command to a file. |
True
|
base_class
|
Type[Job]
|
The base class of the job. |
ThreadJob
|
callback
|
Optional[Callable[[Any], None]]
|
The callback function. |
None
|
error_callback
|
Optional[Callable[[Exception], None]]
|
The error callback function. |
None
|
retries
|
int
|
The number of retries. |
0
|
retry_time_delta
|
float
|
The time delta between retries. |
0.0
|
name
|
Optional[str]
|
The name of the job. |
None
|
condition
|
Optional[Condition]
|
The condition of the job. |
None
|
wait_time_delta
|
float
|
The time delta between each check. |
0.01
|
redirect_out_err
|
bool
|
Whether to redirect stdout and stderr to files. |
False
|
target_dir
|
str
|
The target directory path for run the command. Use '$cache_dir' to represent the cache directory of the job. Use '$current_dir' to represent the current directory of the job. Default is '$current_dir'. |
'$current_dir'
|
popen_kwargs
|
Optional[Dict[str, Any]]
|
The keyword arguments for subprocess.Popen. |
None
|
**attrs
|
Other attributes of the job. |
{}
|
Source code in executor/engine/job/extend/subprocess.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 | |
executor.engine.job.extend.WebappJob(web_launcher, ip='127.0.0.1', port=None, base_class=ProcessJob, check_times=6, check_delta=1.0, callback=None, error_callback=None, retries=0, retry_time_delta=0.0, name=None, condition=None, wait_time_delta=0.01, redirect_out_err=False, **attrs)
Create a job that runs a web app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
web_launcher
|
Union[LauncherFunc, str]
|
The function to launch the web app. The function should accept two arguments: ip and port. |
required |
ip
|
str
|
The ip address of the web app. |
'127.0.0.1'
|
port
|
Optional[int]
|
The port of the web app. If None, will find a free port. |
None
|
base_class
|
Type[Job]
|
The base class of the job. |
ProcessJob
|
check_times
|
int
|
The number of times to check the web app. |
6
|
check_delta
|
float
|
The time delta between each check. |
1.0
|
callback
|
Optional[Callable[[Any], None]]
|
The callback function. |
None
|
error_callback
|
Optional[Callable[[Exception], None]]
|
The error callback function. |
None
|
retries
|
int
|
The number of retries. |
0
|
retry_time_delta
|
float
|
The time delta between retries. |
0.0
|
name
|
Optional[str]
|
The name of the job. |
None
|
condition
|
Optional[Condition]
|
The condition of the job. |
None
|
wait_time_delta
|
float
|
The time delta between each check. |
0.01
|
redirect_out_err
|
bool
|
Whether to redirect stdout and stderr to files. |
False
|
**attrs
|
Other attributes of the job. |
{}
|
Source code in executor/engine/job/extend/webapp.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
executor.engine.job.extend.SentinelJob(func, sentinel_condition, job_type='process', time_delta=0.01, sentinel_attrs=None, **attrs)
Submit a job when the sentinel condition is met.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
The function to be executed. |
required |
sentinel_condition
|
Condition
|
The sentinel condition. |
required |
job_type
|
Union[str, Type[Job]]
|
The type of the job. |
'process'
|
time_delta
|
float
|
The time delta between each check of the sentinel condition. |
0.01
|
sentinel_attrs
|
Optional[dict]
|
The attributes of the sentinel job. |
None
|
**attrs
|
The attributes of the job. |
{}
|
Source code in executor/engine/job/extend/sentinel.py
executor.engine.job.extend.CronJob(func, time_condition, job_type='process', time_delta=0.01, sentinel_attrs=None, **attrs)
Submit a job periodically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable
|
The function to be executed. |
required |
time_period
|
The time period. |
required | |
job_type
|
Union[str, Type[Job]]
|
The type of the job. |
'process'
|
time_delta
|
float
|
The time delta between each check of the sentinel condition. |
0.01
|
sentinel_attrs
|
Optional[dict]
|
The attributes of the sentinel job. |
None
|
**attrs
|
The attributes of the job. |
{}
|