I've actually tried adding ThreadingMixIn to WSGIServer and it worked like a
charm in my case.
Here's the code I added:
from django.test.testcases import LiveServerThread, QuietWSGIRequestHandler
from django.core.servers.basehttp import WSGIServer
from socketserver import ThreadingMixIn
class ThreadedWSGIServer(ThreadingMixIn, WSGIServer):
pass
class ThreadedLiveServerThread(LiveServerThread):
def _create_server(self, port):
return ThreadedWSGIServer((self.host, port), QuietWSGIRequestHandler)
class ThreadedLiveServerTestCase(LiveServerTestCase):
@classmethod
def _create_server_thread(cls, host, possible_ports, connections_override):
return ThreadedLiveServerThread(
host,
possible_ports,
cls.static_handler,
connections_override=connections_override,
)
(just in case, same on pastebin: http://pastebin.com/wTBCWQKJ
<http://pastebin.com/wTBCWQKJ>)
> On 24 Aug 2016, at 21:46, roboslone <[email protected]> wrote:
>
> In answer ti "Any idea how complex the patch would be?" in
> https://code.djangoproject.com/ticket/25970#comment:2 I think using
> socketserver.ThreadingMixin with django.core.servers.WSGIServer would do the
> job. Not completely sure about consequences though...
>
> вторник, 23 августа 2016 г., 19:59:40 UTC+3 пользователь roboslone написал:
> Hi!
>
> I'm trying to simulate timeouts on client to test my app's behaviour with
> requests, that take too much time. I want to use Django's test client for
> that and supply timeout arg for each request (like in requests
> <http://docs.python-requests.org/en/master/user/advanced/#timeouts>), but
> django.test.client.Client doesn't support timeouts.
>
> Here's a ticket about that: https://code.djangoproject.com/ticket/27112
> <https://code.djangoproject.com/ticket/27112>
>
> --
> 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 [email protected]
> <mailto:[email protected]>.
> To post to this group, send email to [email protected]
> <mailto:[email protected]>.
> Visit this group at https://groups.google.com/group/django-developers
> <https://groups.google.com/group/django-developers>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-developers/382280b3-2132-47d5-a051-d47c18fda646%40googlegroups.com
>
> <https://groups.google.com/d/msgid/django-developers/382280b3-2132-47d5-a051-d47c18fda646%40googlegroups.com?utm_medium=email&utm_source=footer>.
> For more options, visit https://groups.google.com/d/optout
> <https://groups.google.com/d/optout>.
--
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 [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-developers/B6E27DEA-2F99-4880-8B3E-1EAAAE95DB11%40gmail.com.
For more options, visit https://groups.google.com/d/optout.