Auto reload on source change

249 views
Skip to first unread message

Jim Steil

unread,
May 19, 2020, 10:34:30 AM5/19/20
to py4web
I can't seem to find how to make the server auto-reload when I make changes to my source.  I'm finding myself restarting the server or reloading from the dashboard whenever I make a change to any file.

Am I missing something obvious?

-Jim

Russell

unread,
May 20, 2020, 6:51:18 PM5/20/20
to py4web
I think this is the only option for now.  I have py4web running on uWSGI with 4 threads and I'm having to restart uWSGI on every code update to make sure all threads are in sync.  I've found that reloading from the dashboard only updates some of the threads.

Hot reloading would certainly be a killer feature!

Jim Steil

unread,
May 21, 2020, 9:26:03 AM5/21/20
to py4web
Not only a killer feature, but a requirement.

Countless times in the past few days I've been making changes only to go test them and not have them work only to realize later that it was because I didn't restart the server (maybe I'm a slow learner).  web2py has me spoiled.  Flask does this very nicely as well.  

-Jim

Jim Steil

unread,
May 21, 2020, 3:49:41 PM5/21/20
to py4web
I've been working with the pip version of py4web so far.

Just today discovered installing the source from github and running there.

This feature is included in the github version.

Start py4web with 

python3 py4web.py run --watch

Now it reloads on file changes.

-Jim

Andrew Rogers

unread,
Aug 11, 2021, 2:28:30 AM8/11/21
to py4web
For those trying to find the py4web equivalent of the 'track_changes' feature in  web2py, Jim has described it above.  It's also outlined in the docs.

Massimo DiPierro

unread,
Aug 11, 2021, 11:12:44 AM8/11/21
to Andrew Rogers, py4web
Notice that yesterday i made watch=lazy the default

--
You received this message because you are subscribed to the Google Groups "py4web" group.
To unsubscribe from this group and stop receiving emails from it, send an email to py4web+un...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/py4web/6ce203f3-e937-4cce-aebb-e0e71592ea0en%40googlegroups.com.

Andrew Rogers

unread,
Aug 12, 2021, 8:40:45 PM8/12/21
to py4web
Great. I was going to suggest that perhaps the default should have been something different.

Andrew Rogers

unread,
Aug 12, 2021, 8:43:02 PM8/12/21
to py4web
Also, I don't really understand what this means from the docs:

  • for immediate reloading (sync-mode): py4web run --watch=sync
  • for reloading on any first incoming request to the application has been changed (lazy-mode): py4web run --watch=lazy

I will update the docs if someone can give me a slightly fuller explanation - especially for 'sync'

Andrew Gavgavian

unread,
Aug 12, 2021, 9:38:45 PM8/12/21
to py4web
Speaking of which Massimo I don't actually see any commit in the Github that has made that change.  Core.py still has off set here.
~Andrew

Nico Zanferrari

unread,
Aug 13, 2021, 4:56:43 AM8/13/21
to Andrew Gavgavian, py4web
It's really changed on the main repo : https://github.com/web2py/py4web/blob/master/py4web/core.py#L1854 , due to this commit.

The difference between the sync and the lazy options is quite simple. If you change any python file under your apps folder, py4web will reload the related app (you can check it in the console):
  • immediately with the sync option
  • at the next request of a web page that is served by that specific app with the lazy option
With the lazy option (now  the default one) you could potentially avoid some unuseful restart of the app between multiple saves.

I'm updating the manual ;-)

nico

Nico Zanferrari

unread,
Aug 13, 2021, 6:59:57 PM8/13/21
to py4web
I've just made PR #620 for updating this (and other minor things) in the manual. 

Note that it's the whole "--watch=lazy" option that is now applied by default, so the following commands are exactly the same:

  • ./py4web.py run apps --watch=lazy
  • ./py4web.py run apps 

nico

Andrew Rogers

unread,
Aug 15, 2021, 6:54:46 PM8/15/21
to py4web
Great. Thanks for the clarification.
Reply all
Reply to author
Forward
0 new messages