What's up Python? Django get background tasks, a new REPL, bye bye gunicorn
Several Python updates include Django's background task integration, a new lightweight Python REPL, Uvicorn's multiprocessing support, and PyPI blocking outlook.com emails to combat bot registrations, enhancing Python development and security.
Read original articleThe article discusses several updates in the Python ecosystem. Django is introducing built-in background tasks to simplify task delegation in multiprocessing settings. A new Python REPL has been released, offering lightweight functionality without the need to install additional dependencies in virtual environments. Uvicorn now supports multiprocessing, eliminating the need for gunicorn in certain scenarios. Additionally, PyPI has blocked outlook.com emails due to ongoing bot account registrations, affecting new associations with PyPI accounts. These changes aim to enhance Python development practices and address security concerns within the ecosystem.
Related
The Prototype's Language
The evolution of programming languages in payments technology sector is discussed, highlighting the shift from COBOL to Java and now to Python for its speed and adaptability. Language choice impacts developers and work quality.
Coverage at a Crossroads
Coverage.py is evolving to reduce execution-time overhead by adopting SlipCover's low-overhead approach for code coverage. Python 3.12's sys.monitoring improves line coverage, but challenges remain for branch coverage. SlipCover's method shows promise, requiring adjustments for optimal results.
What scripting languages come out of the box on Debian 12?
The article discusses pre-installed scripting languages in Debian 12: bash, Python 3, awk, sed, and Perl. Emphasizes convenience for offline work, ease of script transfer, and benefits of learning Python.
Gren 0.4: New Foundations
Gren 0.4 updates its functional language with enhanced core packages, a new compiler, revamped FileSystem API, improved functions, and a community shift to Discord. These updates aim to boost usability and community engagement.
The Death of the Junior Developer – Steve Yegge
The blog discusses AI models like ChatGPT impacting junior developers in law, writing, editing, and programming. Senior professionals benefit from AI assistants like GPT-4o, Gemini, and Claude 3 Opus, enhancing efficiency and productivity in Chat Oriented Programming (CHOP).
You can turn a fresh Debian machine into a running Django web app by just doing:
apt install -y python3-django apache2 libapache2-mod-wsgi-py3
And then creating the one file Django needs:/var/www/mysite/mysite/wsgi.py:
import os
import django
from django.core.wsgi import get_wsgi_application
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'mysite.wsgi')
application = get_wsgi_application()
ROOT_URLCONF = 'mysite.wsgi'
SECRET_KEY = 'hello'
def index(request):
return django.http.HttpResponse('This is the homepage')
def cats(request):
return django.http.HttpResponse('This is the cats page')
urlpatterns = [
django.urls.path('', index),
django.urls.path('cats', cats),
]
And then telling Apache where to look for it:/etc/apache2/sites-enabled/000-default.conf:
ServerName 127.0.0.1
WSGIPythonPath /var/www/mysite
<VirtualHost *:80>
WSGIScriptAlias / /var/www/mysite/mysite/wsgi.py
<Directory /var/www/mysite/mysite>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
And voilá, you have a running Django application, which you can expand upon to any size and complexity.If you want to try it in a docker container, you can run
docker run -it --rm -p80:80 debian:12
perform the steps above and then access the Django application at 127.0.0.1Despite being somewhat out of fashion, Python and Django continue to serve more down to earth software development well after so many years. I picked it up around 2007 (remember the "magic removal" branch), and it only got better ever since. Many call Python "toy language" or "data scientist language" but the truth is that 99.9% of modern web development is database-backed and, unless you have some strictly computational tasks behind your APIs, the fact that e.g. Rust is 100x "faster" than Python is mostly meaningless. Django just works. Of course, there can be different personal preferences, but I'm really amazed by the project that is closing in on 20 years that is still absolutely relevant and a joy to work with.
@tasks.cron("*/5 * * * *") # every 5 minutes
async def infrequent_task():
...
In addition Hypercorn, https://github.com/pgjones/hypercorn, (a ASGI and WSGI) also does not use gunicorn, having migrated many years ago.That said, boy does Django must change it's current strategy...
RoR and Laravel have been getting all sort of goodies baked in the framework itself such as tasks queue, nice admin features, integration with frontend technologies (scss, js, even jsx/tsx), even entire packages to manage payment systems, mailing and so on... Good quality features that are ready to use and are integrated inside the framework, which easy to use APIs and fantastic admin integration.
Django devs, on the other hand, have been (imho) ignoring the users (devs) and have been denying any and all attempts at bringing something similar to Django. There are at least half a dozen packages for each "thing" that you want to do, and some are in a very good shape, but others are just hopelessly broken. What's even worse, because they're not part of Django, most of the time there are some edge cases that just can't be implemented without subclassing Django's core.
One of the most recent examples being Django's support for async operations. Except that Django itself doesn't provide a nice way to create / expose an API, which is why people use DRF. But DRF doesn't support async, which is why you need to add "adrf" (https://github.com/em1208/adrf) to DRF. But adrf doesn't support async generic viewsets, so you must add aiodrf (https://github.com/imgVOID/aiodrf) to adrf. But aiodrf doesn't support (...) you get the point. You end up in a situation in which you're pilling packages on top of packages on top of packages just so you can have an asynchronous API. Madness.
Supporting scss it another example of pilling packages on top of packages. It just never ends...
I can't express the desire I have for Django to start integrating packages into its core and get on par with RoR and Laravel.
/rant
Is Django-tasks the solution that would permit this to be built?
Edit: Ooops. IPython magics don't seem to work. I hope they add it.
I wish they could make it easy to deploy django or other python framework in a serverless function with decent security baked in.
Related
The Prototype's Language
The evolution of programming languages in payments technology sector is discussed, highlighting the shift from COBOL to Java and now to Python for its speed and adaptability. Language choice impacts developers and work quality.
Coverage at a Crossroads
Coverage.py is evolving to reduce execution-time overhead by adopting SlipCover's low-overhead approach for code coverage. Python 3.12's sys.monitoring improves line coverage, but challenges remain for branch coverage. SlipCover's method shows promise, requiring adjustments for optimal results.
What scripting languages come out of the box on Debian 12?
The article discusses pre-installed scripting languages in Debian 12: bash, Python 3, awk, sed, and Perl. Emphasizes convenience for offline work, ease of script transfer, and benefits of learning Python.
Gren 0.4: New Foundations
Gren 0.4 updates its functional language with enhanced core packages, a new compiler, revamped FileSystem API, improved functions, and a community shift to Discord. These updates aim to boost usability and community engagement.
The Death of the Junior Developer – Steve Yegge
The blog discusses AI models like ChatGPT impacting junior developers in law, writing, editing, and programming. Senior professionals benefit from AI assistants like GPT-4o, Gemini, and Claude 3 Opus, enhancing efficiency and productivity in Chat Oriented Programming (CHOP).