(jobs, limit)
| 128 | |
| 129 | |
| 130 | def simulate(jobs, limit): |
| 131 | |
| 132 | time = 0 |
| 133 | |
| 134 | # summarise(jobs) |
| 135 | |
| 136 | while True: |
| 137 | # Check if any have ended |
| 138 | for job in jobs: |
| 139 | if job.status == "active": |
| 140 | if time >= job.started + job.length: |
| 141 | # print("{}/{} Finished:".format(count_status(jobs, "active"), limit)) |
| 142 | job.ended = time |
| 143 | job.status = "finished" |
| 144 | # print(job) |
| 145 | |
| 146 | # Check if any can start |
| 147 | for job in jobs: |
| 148 | if job.status == "not started": |
| 149 | if count_status(jobs, "active") < limit: |
| 150 | # print("{}/{} Starting:".format(count_status(jobs, "active"), limit)) |
| 151 | job.started = time |
| 152 | job.status = "active" |
| 153 | # print(job) |
| 154 | |
| 155 | time += 1 |
| 156 | |
| 157 | # Exit loop? |
| 158 | if count_status(jobs, "finished") == len(jobs): |
| 159 | break |
| 160 | |
| 161 | summarise(jobs) |
| 162 | |
| 163 | |
| 164 | def do_thing(repo, number): |
no test coverage detected