ApplicationRunner API improvements
See original GitHub issueCurrently, the “usual” way to run an ApplicationSession
-derived component is via the ApplicationRunner
API. This lumps together several things:
- creates the component (ComponentConfig + instantiating the session)
- possibly sets up TLS options, if
wss://
URI - starts the event-loop (
reactor.run()
for Twisted orrun_until_complete
in asyncio). - starts logging (via
txaio.start_logging
). - handles several error-cases
This becomes awkward for certain use-cases, and e.g. spawned a start_reactor=bool
kwarg for the Twisted version (which also lumps in logging, because start_logging
is only called if it starts the reactor itself).
- users wanting to start their own logging (e.g. https://github.com/crossbario/txaio/issues/75#issuecomment-216651341)
- users wanting to run the event-loop elsewhere (e.g.
start_reactor=
kwarg) - users who want to handle errors themselves
I am filing this bug to collect these use-cases as a way to improve the “I wish to run a component” API to ensure they’re covered.
Issue Analytics
- State:
- Created 7 years ago
- Reactions:1
- Comments:8 (5 by maintainers)
Top Results From Across the Web
How to use ApplicationRunner in Spring Boot application?
Let's Jump to Code. As per API documentation, ApplicationRunner is an Interface, so we cannot create an instance of it, but we can...
Read more >Spring Boot Features
This section dives into the details of Spring Boot. Here you can learn about the key features that you may want to use...
Read more >App wrapper on top of ApplicationRunner #208 - GitHub
App wrapper on top of ApplicationRunner #208 ... The use of Context changes the API of every procedure/handler. It cannot be any longer...
Read more >SEP-13: unify high- and low-level user applications in YARN and ...
ApplicationRunner only supports high-level API and does not fully support low-level ... A high-level overview of the proposed changes is illustrated below:.
Read more >When and why do we need ApplicationRunner and Runner ...
These runners are used to run the logic on application startup, for example spring boot has ApplicationRunner(Functional Interface) with run ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I subscribe to this. IMHO, the ApplicationRunner does too much of magic (well, it’s not magic at all, the code is very short and easy to understand, but you have to check what is going on here when you are discovering autobahn-python), i.e. running the loop and closing the loop. I think this should be done explicitly by the user (or there should be a way to do it manually, if the default is doing all the machinery of the loop) because, when writing software that has already asyncio components, it’s a bit strange not being able to start the loop by yourself, or adding an autobahn component to an already running loop/software, more over, when the connection to the router is lost, the complete program stops (because the loop is stopped), and, if i.e. you want to do asyncio things to clean stuffs (i.e, start an asyncio commit to db, continue running tasks and restart a new session,…) you can’t. I know you can subclass ApplicationRunner to change all those things, by I’m more or less convinced that’s what will happen to the majority of users, rewriting ApplicationRunner in a way or another, so, maybe there is some value to rethink the thing. I also find the documentation should emphase ApplicationRunner is designed for quick tests and development and is likely to be subclassed for more complex setup.
It is indeed very annoying not to be able to control logging (I have been struggling to find why logging was duplicate), and the event loop (most asyncio code allows to pass an arbitrary loop to be used).