Re:Django 3
by andrewgodwin on Monday December 02, 2019 @11:21AM
(#21683816)
I've replied to the post on the forum, but if this is the default way Jupyter runs then we're going to have to figure something out longer-term. Calling the Django ORM from an async thread just isn't safe...
Thanks for the reply and all of the great work.
Using django in a notebook is definitely not a typical use case so I wouldn't worry about it too much.
Ideally the ORM would be a standalone package that could be used outside of the web server context. (I know sqlalchemy is an option but then you lose all of the benefits of django)
Our developers love to work in notebooks running Django, it lets you iterate extremely fast.
Andrew already has a PR to fix this issue https://github.com/django/django/pull/12172
The ORM has been essentially unusable from my perspective since day 1
Re:Django 3
by dinkleberg on Monday December 02, 2019 @07:30PM
(#21688695)
Why is that?
Try doing some simple joins, subqueries, unions, etc., and you’ll quickly see why. If you’re able to find the correct incantation, you’ll quickly see that the Django ORM builds awful queries that perform horribly. I’ve found the Django ORM to make simple things hard and hard things harder.
Re:Django 3
by singularity2001 on Monday December 02, 2019 @10:00AM
(#21682866)
please tell me that python did not adopt the javascript async hell. async should be an optional keyword on the CALLER side, not an invisible trait of the function. go figure()
It didn't, async await is just syntactic sugar on top of coroutines/futures. You can define an sync function and get a coroutine back if you call it without await.
It's still kind of a mess though because you have two universes that are not really compatible, forcing you to rewrite everything that touches IO. For django that probably means a rewrite of the ORM, caching and middlewares.
JS async/await is also just syntactic sugar on top of Promises (which are basically just futures with the ability to write as well).
In Javascript, async is an optional parameter on the caller side. (Well, 'await' is, but I figure that's what you mean). It can be used with any function call, not just those that are marked async. Though it only make sense to use it with Promise-returning functions.
Alternatively, you can also use it with a plain Promise, which makes for a nice mutex. I've also used this for imitating async constructors, which is not currently possible.
https://stackoverflow.com/questions/59119396/how-to-use-djan...
https://forum.djangoproject.com/t/is-there-a-way-to-disable-...