chalice icon indicating copy to clipboard operation
chalice copied to clipboard

chalice local stuck 'Restarting local dev server'

Open saliaaa opened this issue 6 years ago • 8 comments

Every time I run chalice local, it gets stuck restarting local dev server. Usually it starts serving ~1 minute or so, sometimes it never ends until I do Ctrl +C. Very rarely it restarts in seconds. I'm running it on Windows 10 through Anaconda prompt

Is there any solution for that?

saliaaa avatar Feb 06 '19 13:02 saliaaa

Are you modifying of your app.py or other files in the meantime? It will restart the dev server whenever it detects you've made changes to your app.py. If you don't want that behavior, you can use the --no-autoreload option.

jamesls avatar Feb 07 '19 01:02 jamesls

No, I'm not modifying anything meantime, just waiting for it to restart server to check if the changes work.

saliaaa avatar Feb 07 '19 08:02 saliaaa

Ah so the issue is that it takes a while for the server to restart? Do you have any module level initialization in your app.py? How long does it take to just import your app?

$ time python -c "import app"

real	0m0.091s
user	0m0.054s
sys	0m0.029s

jamesls avatar Feb 07 '19 21:02 jamesls

I had a bit of a similar problem with the SQS entrypoint, it seems to always restart at least once. I will investigate.

Sytten avatar Feb 08 '19 02:02 Sytten

@jamesls Yes, it keeps printing Restarting local dev server for many times. All I have is importing some custom functions from chalicelib, POST request route and 2 global variables.

How long does it take to just import your app?

As I'm using windows, running Measure-Command {python -c "import app"} gives: TotalMilliseconds : 678.3171

saliaaa avatar Feb 08 '19 14:02 saliaaa

@Sytten are you also on windows? I've been trying to repro on my mac, perhaps it's something specific to windows.

jamesls avatar Feb 08 '19 21:02 jamesls

No I am also on mac, the server seems to only restart once in my case and only for sqs triggers.

Sytten avatar Feb 09 '19 05:02 Sytten

I have the same behavior on Chalice version 1.28 I wanted to call function, but it restarts server every 5 sec and in the logs it writes

2023-05-24 19:04:17.043 | INFO | app::298 - STAGE: Stage.LOCAL Serving on http://127.0.0.1:8000 Restarting local dev server. Credentials found in config file: ~/.aws/config 2023-05-24 19:04:23.247 | INFO | app::298 - STAGE: Stage.LOCAL Serving on http://127.0.0.1:8000 Restarting local dev server. Credentials found in config file: ~/.aws/config

Maybe there are ideas how to make it not restart the server? I will be very grateful to you!

beskrovnykh avatar May 24 '23 11:05 beskrovnykh