Commit 2b059ff
committed
Fix threshold subscription to prevent duplicate callbacks
Changes the ContinuousObservable threshold system from storing callbacks
directly to using a signal-based subscription pattern:
- Change `_thresholds` from dict to set (stores threshold values only)
- Update `add_threshold()` to check for existing subscriptions before
subscribing to prevent duplicate callback invocations
- Separate concerns: thresholds define WHICH values to watch, observers
define WHO to notify when crossed
- Add ValueError when attempting to add threshold to non-ContinuousObservable
This fixes an issue where registering multiple thresholds with the same
callback would cause it to be called multiple times per threshold crossing.1 parent b4a1660 commit 2b059ff
1 file changed
+21
-7
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
| 479 | + | |
| 480 | + | |
| 481 | + | |
| 482 | + | |
| 483 | + | |
| 484 | + | |
| 485 | + | |
| 486 | + | |
| 487 | + | |
| 488 | + | |
| 489 | + | |
| 490 | + | |
| 491 | + | |
| 492 | + | |
| 493 | + | |
480 | 494 | | |
481 | 495 | | |
482 | 496 | | |
| |||
487 | 501 | | |
488 | 502 | | |
489 | 503 | | |
490 | | - | |
| 504 | + | |
491 | 505 | | |
492 | 506 | | |
493 | 507 | | |
| |||
624 | 638 | | |
625 | 639 | | |
626 | 640 | | |
627 | | - | |
| 641 | + | |
628 | 642 | | |
629 | | - | |
630 | | - | |
| 643 | + | |
| 644 | + | |
631 | 645 | | |
632 | | - | |
633 | | - | |
| 646 | + | |
| 647 | + | |
634 | 648 | | |
635 | 649 | | |
636 | 650 | | |
| |||
0 commit comments