(sensor_index, how_many)
| 61 | return 1 |
| 62 | |
| 63 | def worker(sensor_index, how_many): |
| 64 | global counter |
| 65 | # I have a barrier in here so the workers synchronize |
| 66 | # when they start counting, otherwise it's hard to get a race |
| 67 | # because the overhead of starting a thread is high. |
| 68 | BARRIER.wait() |
| 69 | for _ in range(how_many): |
| 70 | data = read_sensor(sensor_index) |
| 71 | # Note that the value passed to += must be a function call or other |
| 72 | # non-trivial expression in order to cause the CPython eval loop to |
| 73 | # check whether it should release the GIL. This is a side-effect of |
| 74 | # an optimization. See https://github.com/python/cpython/commit/4958f5d69dd2bf86866c43491caf72f774ddec97 for details. |
| 75 | counter += get_offset(data) |
| 76 | |
| 77 | |
| 78 | print("Example 2") |
nothing calls this directly
no test coverage detected