Profile picture
, 7 tweets, 2 min read Read on Twitter
1/ #Django will use watchman to do autoreload if it's installed since 2.2. The default reloader runs stat on all the files in your project once per second, whereas watchman will use os file system events, which is much more efficient.
2/ I never cared about this until I spent an afternoon figuring out why Docker for Mac's hyperkit process sits on 120% - 150% cpu use while running my mid sized django project in a container.
3/ i used 'docker stats' to deduce which container, then 'top' and 'ps auxf' to work out which python process was the problem. Then did a thread dump of the django server using faulthandler.dump_traceback() triggered from an API call, and then 'docker log'
4/ I was expecting some crazy background thread was doing something weird, but nope, just the autoreload loop, launched from StatReloader. Reading the source revealed the WatchmanReloader.
5/ Installing watchman into the container solved the issue. It didn't initially work because of some old code accidentally adding / to sys.path, and watchman refused to monitor /. I traced through watchman using pdb to work out why. This took a while.
6/ aside: knowing #pdb is a great skill. It's available inside containers and servers where you couldn't easily otherwise use a debugger. It'll probably be in python forever. You can exec arbitrary python inside your process.
7/ anyway, all this is a non issue unless you're using #docker for mac, where the host i/o is just so so so very slow and has been for years. I wish there was an alternative. But happy days - after I did this, hyperkit only uses 20% cpu for no reason. Yay!
Missing some Tweet in this thread?
You can try to force a refresh.

Like this thread? Get email updates or save it to PDF!

Subscribe to James Salter
Profile picture

Get real-time email alerts when new unrolls are available from this author!

This content may be removed anytime!

Twitter may remove this content at anytime, convert it as a PDF, save and print for later use!

Try unrolling a thread yourself!

how to unroll video

1) Follow Thread Reader App on Twitter so you can easily mention us!

2) Go to a Twitter thread (series of Tweets by the same owner) and mention us with a keyword "unroll" @threadreaderapp unroll

You can practice here first or read more on our help page!

Follow Us on Twitter!

Did Thread Reader help you today?

Support us! We are indie developers!


This site is made by just three indie developers on a laptop doing marketing, support and development! Read more about the story.

Become a Premium Member ($3.00/month or $30.00/year) and get exclusive features!

Become Premium

Too expensive? Make a small donation by buying us coffee ($5) or help with server cost ($10)

Donate via Paypal Become our Patreon

Thank you for your support!