Ephes Blog

Miscellaneous things. Mostly Weeknotes and links I stumbled upon.

Date -

Serving Files With Django - DjangoCon Europe 2021 Talk

, Jochen
On this years DjangoCon Europe I did a talk about file serving with Django (link to the slides):

Update 2021-07-31 - the talk was uploaded to YouTube including the Q&A-session:

DjangoCon 2021 | Serving Files with Django | Jochen Wersdörfer

Usually it's recommended to use a dedicated webserver like nginx or a CDN to serve static / user uploaded files when using Django. But after it's now (august 2020) possible to use async / await syntax in Django views, I thought it might be time to revisit this recommendation. It now should be possible to write views that are not blocking a complete worker process for the entire response serving time.

The code for returning async file responses is available via this django_fileresponse package. The process of building this package was also documented on my twitch stream (youtube playlist).

Weeknotes 2021-06-28

, Jochen
Work on django_fileresponse goes on and it's now in a somewhat usable state. Recorded progress in four more streams / videos. We recorded a new podcast episode about DjangoCon Europe 2021. Joined the jazzband organisation to be able to just fix projects instead of forking and doing a PR maybe later (after Django releases for example..). After ruling out any other possible source for the strange noises I hear in my guitar sound, I replaced the cables between my guitar and the mixer in my audio setup. It was the cables \o/.

Interesting Articles / Podcast Episodes

Weeknotes 2021-06-21

, Jochen
Worked a little bit on django_fileresponse and started live streaming. Atm I stream to twitch and later upload the videos to youtube, too. The stream is about creating a podcast hosting application as a SaaS product. Being able to serve files directly from the application server is important for a podcast hosting application, therefore I started building some infrastructure to be able to do this.

For django_fileresponse I used nbdev because I liked the concept and you get a lot of infrastructure (python package, documentation) for free. But having a package with name that differs from the path from where you want to import code (django_fileresponse vs from fileresponse import x) breaks nbdev_build_docs so I had to replace this command line utility which patches the settings.ini on the fly. It was probably more effort to adapt nbdev to this than using a proper django package template, but now it works :).

Created an django example project whithin django_fileresponse and learned a little bit more about magic commands in jupyter notebooks. Serving files using gunicorn with uvicorn is working now. Had to modify the Django ASGIHandler to make it possible. I'm still not sure what's the best way to swap the default ASGIHandler with a modified version from a projects perspective (being explicit, monkeypatching..).

Serving files asynchronously from MinIO is now also possible and most of the streaming data to the client related code is shared with the class that serves files asynchronously from the filesystem.

Worked on my streaming setup too and tried to bring some structure into the mess of cables behind my desk. But it didn't improve much. Felt more like an expedition into the cable dungeon. Happy to be back alive. In preparation for the next Python Podcast episode I tried to watch most of the 2021 DjangoConEu Talks.

Interesing Articles / Podcast Episodes