How can a developer saving a python file trigger a reload of bench start?

Hi folks

I have a Frappe and ERPNext installation, along with a custom application running under Ubuntu 20.04 on WSL.

If I touch a file from WSL, or save it from the PC side, the ‘bench start’ doesn’t seem to trigger a recompile. I have to Ctrl+C out of bench and run bench start again. This makes the edit / compile / debug cycle longer of course.

Is there any way for bench start to watch for changed python files?

Thank you,

== John ==

Hi there,

I don’t have a solution to your problem, except to say that developer mode (bench start) should already be watching your source files for changes. On my dev system, saving changes to a .py file will cause the server to reload automatically (while noting the change in console).

Thanks. That’s weird, I wonder why mine doesn’t.

The file system is on the “C” drive and I’m accessing as /mnt/c/stuff/erpnext/apps/myapp on the Linux side. I tried ‘touch’ strictly on the Linux side as well.

== John ==

Very odd indeed. Unfortunately, I don’t have much insight into how filesystem triggers work, especially when working on WSL. I hope someone else will be able to answer.

Thanks @peterg

Well, another point of interest is that if I switch the Linux side over to a native mount point, instead of the C volume, it triggers the recompile.

i.e. /mnt/c/erpnext/apps/myapp
vs
~/erpnext/apps/myapp

This defeats the entire point of WSL (which isn’t Frappe’s issue), which is that I could use my Windows native IDE’s to edit Frappe/ERPNext/CustomApp code directly.

So, the next step is to set up remote python debugging, which defeats the point of using WSL at all, I’ll just debug on our cloud servers.

== John ==

Hello @JohnGwinner,

I’ve been developing on WSL without any issues for about 8 months. I’ve worked on it with VSCode, and PyCharm. Both of these IDEs support WSL.

Since my last post, I’ve played around with WSL a bit. When running on C volume, I had lots of issues and a massive performance drop. I am not at all surprised to learn that filesystem event triggers aren’t being caught by frappe, and I suspect that this isn’t something the frappe devs can do anything about.

If working in the native mount point is possible for your toolchain, I highly recommend it. I’ve been very pleased with my experience on WSL.