Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread GMail
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 T

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread roboslone
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

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread GMail
Wow, that was a quick response! Tim, is there a way for me to join the discussion? Is there another mail thread? > On 24 Aug 2016, at 21:36, Tim Graham wrote: > > multithreading support has been proposed a couple times but it hasn't passed > the discussion stage yet. > > https://code.djangopro

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread GMail
I found this ticket about same issue: https://code.djangoproject.com/ticket/20238 It was closed 2 years ago and one of the reasons is that use case was considered "somewhat fictional". I personally think my case is very real :) I'm thinking about us

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread Tim Graham
multithreading support has been proposed a couple times but it hasn't passed the discussion stage yet. https://code.djangoproject.com/ticket/20238 https://code.djangoproject.com/ticket/25970 On Wednesday, August 24, 2016 at 2:21:07 PM UTC-4, roboslone wrote: > > So I've tried LiveServerTestCase

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread GMail
So I've tried LiveServerTestCase and it seems that live server is single-threaded. If client timeout is 5 seconds, then LiveServerTestCase works fine for slow requests, that take from 1 to 9 seconds to process. Second try will send request to the same thread and client will get TimeoutError ins

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread GMail
I didn't try LiveServerTestCase yet (and to be honest never heard of it before), I'll give it a try. Thanks! > On 24 Aug 2016, at 17:19, Shai Berger wrote: > > Yes, the prototype I mentioned is a PR against Django, except that if it is > intended to clarify the request rather than supply it,

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread Shai Berger
Yes, the prototype I mentioned is a PR against Django, except that if it is intended to clarify the request rather than supply it, it doesn't have to be full -- e.g. it doesn't need tests or documentation untill we decide we want the feature in. But before you go there -- isn't LiveServerTestCa

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread GMail
"Players" are backends (Django) and load balancer that proxies all user requests on one of the backends. In my case load balancer has small backend timeout (default is 3 sec, preferable is 1 sec) and it will send the same request (with the same X-Request-Id header) to another backend after this

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread Shai Berger
On Wednesday 24 August 2016 14:33:34 Александр Христюхин wrote: > Actually network is not an issue here. I'm using locks in distributed cache > to manage requests between backends and that's what I want to test. In this > case calling Django directly is okay. > I am sorry, then; it seems I have m

Re: Simulating timeouts on client with django.test.client.Client

2016-08-24 Thread Александр Христюхин
Actually network is not an issue here. I'm using locks in distributed cache to manage requests between backends and that's what I want to test. In this case calling Django directly is okay. вторник, 23 августа 2016 г., 23:16:10 UTC+3 пользователь Shai Berger написал: > > Hi, > > Just to make i

Re: Simulating timeouts on client with django.test.client.Client

2016-08-23 Thread Shai Berger
Hi, Just to make it clear: Based on the ticket, you want to test how the server acts when facing client timeouts and/or disconnects. Please correct me if I'm wrong. Assuming I'm right, the test client seems like the wrong tool for this job, because it doesn't actually make network connections;

Re: Simulating timeouts on client with django.test.client.Client

2016-08-23 Thread Tim Graham
Have you tried writing your own subclass of the test client (or writing a patch for Django's own test client) so we can see what it looks like? (I suggested writing to the mailing list to get other feedback because I'm not sure if this is a good idea or even feasible.) On Tuesday, August 23, 20

Simulating timeouts on client with django.test.client.Client

2016-08-23 Thread Александр Христюхин
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 ), but djang