MCPcopy Create free account
hub / github.com/mlco2/codecarbon / busy_task

Function busy_task

examples/task_loop_same_task.py:12–21  ·  view source on GitHub ↗
(duration_secs=4)

Source from the content-addressed store, hash-verified

10
11
12def busy_task(duration_secs=4):
13 print(f" Task: Starting busy work for ~{duration_secs} seconds...")
14 start_time = time.perf_counter()
15 while time.perf_counter() - start_time < duration_secs:
16 # Simulate some CPU work
17 # for _ in range(100000): # Adjust complexity as needed
18 # pass
19 time.sleep(2)
20 end_time = time.perf_counter()
21 print(f" Task: Finished busy work in {end_time - start_time:.2f} seconds.")
22
23
24max_rounds = 20 # Safety break for the loop

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…