launch server as task?
See original GitHub issueCurrently uvicorn.run()
calls Server.run(...)
which calls loop.run_until_complete(...)
. Additionally uvicorn insists on starting the loop itself too (in setup_loop)
As such, it is made very difficult to launch other tasks in the same process.
Is there a way to launch the server as just a task on the loop and have the ability to schedule additional tasks on the loop?
IIUC there were some related issues in the past but not clear to me what is going to happen with these.
Issue Analytics
- State:
- Created 4 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
Schedule a server process in - Windows - Microsoft Learn
Schedule the Task. Click Start, point to Control Panel, then point to Scheduled Tasks, and then click Add Scheduled Task.
Read more >How can I run a scheduled task as SYSTEM - Super User
Go to Start > Administrative Tools > Task Scheduler; In the Task Scheduler window click "Create Task" on the right hand bar under...
Read more >Automatically starting a server when starting a debug session ...
The `start server` task is a `shell` task, should run in the background and the command it executes is `http-server`, which is the...
Read more >How to configure your server to run Scheduled Tasks
1) Go to Start → Control Panel → Administrative Tools → Task Scheduler (or Scheduled Tasks on earlier versions of Windows) · 2)...
Read more >9 ways to start the Task Scheduler in Windows (all versions)
You can open the Task Scheduler using the Task Manager too. Press the Ctrl + Shift + Esc keys on your keyboard to...
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
Hi @toonknapen ,
This is a problem that I’ve had to solve, so I wrote a blog entry on it here. I think the bit right at the end might be what you’re looking for.
We’ve added a
Config(loop="none")
option now, if you really need it. Also seeserver.serve(...)
if you want to run the uvicorn server from within an existing async context.On the whole the ASGI lifespan messaging is the right way to include application startup or scheduled background tasks.
I’m wondering if we ought to include a
startup=<some_func>
andshutdown=<some_func>
options, that hook in startup and shutdown tasks easily? That might be easier for folks in cases where they’re not using an application framework that provides those hooks itself?