Marks the API as started and runs all startup handlers
(self)
| 621 | self.startup_handlers.append(handler) |
| 622 | |
| 623 | def _ensure_started(self): |
| 624 | """Marks the API as started and runs all startup handlers""" |
| 625 | if not self.started: |
| 626 | async_handlers = [ |
| 627 | startup_handler |
| 628 | for startup_handler in self.startup_handlers |
| 629 | if introspect.is_coroutine(startup_handler) |
| 630 | ] |
| 631 | if async_handlers: |
| 632 | loop = asyncio.get_event_loop() |
| 633 | loop.run_until_complete( |
| 634 | asyncio.gather(*[handler(self) for handler in async_handlers], loop=loop) |
| 635 | ) |
| 636 | for startup_handler in self.startup_handlers: |
| 637 | if not startup_handler in async_handlers: |
| 638 | startup_handler(self) |
| 639 | |
| 640 | @property |
| 641 | def startup_handlers(self): |
no outgoing calls