importing threading and dummy_threading

94 views
Skip to first unread message

Tim Graham

unread,
Jan 28, 2015, 8:51:16 AM1/28/15
to django-d...@googlegroups.com
As far back as Django 1.4 (didn't check earlier), we use both these patterns in the code:

import threading

try:
    import threading
except ImportError:
    import dummy_threading as threading

We also have logic in tests to skip if threading isn't available, however, I can't believe that Django is usable without threading given we use the first style of import (without a fallback) in many places (db.models.loading, db.utils, test.testcases, + more).

Docs say:

"The dummy_threading module is provided for situations where threading cannot be used because thread is missing."
https://docs.python.org/2/library/threading.html

"The [thread] module is optional. It is supported on Windows, Linux, SGI IRIX, Solaris 2.x, as well as on systems that have a POSIX thread (a.k.a. “pthread”) implementation."
https://docs.python.org/2/library/thread.html#module-thread

This doesn't answer the question of what systems it *is* needed on. Unless there's an objection, I think we can remove dummy_threading fallbacks?

Tim Graham

unread,
Jan 28, 2015, 9:32:29 AM1/28/15
to django-d...@googlegroups.com
Here's a 9 year old ticket referencing freebsd5.1...

https://code.djangoproject.com/ticket/2052

Marc Tamlyn

unread,
Jan 28, 2015, 9:37:52 AM1/28/15
to django-d...@googlegroups.com
Given that it already doesn't worth without full threading in the previous LTS, I don't think we need to worry about it.

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/2147f7e7-1251-42ff-81e2-ad3b453060a5%40googlegroups.com.

For more options, visit https://groups.google.com/d/optout.

Tim Graham

unread,
Jan 28, 2015, 10:27:27 AM1/28/15
to django-d...@googlegroups.com
Done in https://github.com/django/django/pull/4003

On a related note, I am curious if anyone is running Django on a platform that lacks cPickle these days. We use this pattern in several places:

try:
    from django.utils.six.moves import cPickle as pickle
except ImportError:
    import pickle
Reply all
Reply to author
Forward
0 new messages