Embedded task scheduler using threading.
| 680 | |
| 681 | |
| 682 | class _Threaded(Thread): |
| 683 | """Embedded task scheduler using threading.""" |
| 684 | |
| 685 | def __init__(self, app, **kwargs): |
| 686 | super().__init__() |
| 687 | self.app = app |
| 688 | self.service = Service(app, **kwargs) |
| 689 | self.daemon = True |
| 690 | self.name = 'Beat' |
| 691 | |
| 692 | def run(self): |
| 693 | self.app.set_current() |
| 694 | self.service.start() |
| 695 | |
| 696 | def stop(self): |
| 697 | self.service.stop(wait=True) |
| 698 | |
| 699 | |
| 700 | try: |