Commit 583be7c
Make Zabbix Calls Non-Blocking
`Background`
The Zabbix Python module performs synchronous API calls, which block the reactor’s
event loop and can potentially cause the master to freeze.
Even worse, the configured timeout can block execution for up to 10 seconds.
After reviewing the official integration documentation (https://www.zabbix.com/integrations/python
), I concluded that no Twisted-compatible module exists that allows asynchronous API calls.
Writing such a module from scratch would be excessive for such a small component.
Since no Twisted integration is available,
I also see no benefit in switching to a different Zabbix module; the current one has served us well.
`Changes`
The solution is to run the synchronous code in a separate thread by passing `getMetric` to `deferToThread`.
This prevents the main thread from being blocked.
The critical section is wrapped in a `try/except` block to ensure that any failureinside `getMetric`,
for example, Zabbix unavailability, missing metrics, or network issues—does not prevent the build from starting.
I also reduced the `timeout` to 3 seconds.
Although the main thread is no longer blocked, Buildbot’s `BuildRequestDistributor`
will not proceed to the next builder’s `build request` until `canStartBuild` has completed.
Reducing the `timeout` prevents unnecessary delays in processing the build request queue1 parent a06600c commit 583be7c
1 file changed
+47
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
5 | | - | |
| 5 | + | |
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
| 9 | + | |
| 10 | + | |
9 | 11 | | |
10 | 12 | | |
11 | 13 | | |
| |||
289 | 291 | | |
290 | 292 | | |
291 | 293 | | |
| 294 | + | |
292 | 295 | | |
293 | 296 | | |
294 | | - | |
| 297 | + | |
295 | 298 | | |
296 | 299 | | |
297 | 300 | | |
298 | 301 | | |
299 | 302 | | |
300 | 303 | | |
301 | | - | |
302 | | - | |
303 | | - | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
304 | 320 | | |
305 | 321 | | |
306 | 322 | | |
| |||
575 | 591 | | |
576 | 592 | | |
577 | 593 | | |
| 594 | + | |
| 595 | + | |
| 596 | + | |
| 597 | + | |
| 598 | + | |
| 599 | + | |
| 600 | + | |
| 601 | + | |
| 602 | + | |
| 603 | + | |
| 604 | + | |
| 605 | + | |
| 606 | + | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
578 | 610 | | |
579 | 611 | | |
580 | 612 | | |
581 | 613 | | |
582 | 614 | | |
583 | | - | |
| 615 | + | |
584 | 616 | | |
585 | 617 | | |
586 | 618 | | |
| |||
590 | 622 | | |
591 | 623 | | |
592 | 624 | | |
593 | | - | |
| 625 | + | |
| 626 | + | |
594 | 627 | | |
595 | 628 | | |
596 | 629 | | |
597 | | - | |
| 630 | + | |
| 631 | + | |
| 632 | + | |
| 633 | + | |
| 634 | + | |
598 | 635 | | |
599 | 636 | | |
600 | 637 | | |
601 | 638 | | |
602 | 639 | | |
603 | 640 | | |
604 | 641 | | |
605 | | - | |
606 | | - | |
| 642 | + | |
| 643 | + | |
607 | 644 | | |
608 | 645 | | |
609 | 646 | | |
| |||
0 commit comments