Monday, May 30, 2016

Re: Simultaneous Web Requests appending responses in function based views



On Mon, May 30, 2016 at 7:16 PM, cr katz <crkatz411@gmail.com> wrote:
The code I shared is where the problem is. Here is the output once again from the server logs. It is evident that the second request is running into the first and appending the responses.

The text in BOLD 'Entered Search' is the entry point for each request. I suspect a problem with looping qList or appending 'p'.

Entered Search
<QueryDict: {u'project': [u'project1'], u'app': [u'app'], u'sdtime': [u'2016-05-30 00:00:00 UTC'], u'days': [u'0'], u'edtime': [u'2016-05-30 00:02:00 UTC']}>
Hello, I am X
Hello, I am Y
Hello, I am A
Entered Search
<QueryDict: {u'project': [u'project1'], u'app': [u'app'], u'sdtime': [u'2016-05-30 00:00:00 UTC'], u'days': [u'0'], u'edtime': [u'2016-05-30 00:02:00 UTC']}>
Hello, I am X
Hello, I am B
Hello, I am Y
[30/May/2016 22:00:35] "GET /search/?project=project1&app=app&days=0&sdtime=2016-05-30+00%3A00%3A00+UTC&edtime=2016-05-30+00%3A02%3A00+UTC HTTP/1.1" 200 893
Hello, I am A
Hello, I am B
[30/May/2016 22:00:58] "GET /search/?project=project1&app=app&days=0&sdtime=2016-05-30+00%3A00%3A00+UTC&edtime=2016-05-30+00%3A02%3A00+UTC HTTP/1.1" 200 1475



The view code you posted will never provide the outputs you've listed here, no matter what the input arguments are.

Your view code will always output all of the elements in the qList variable (and consequently append() all of the values to p). You're not doing any filtering through the for loop where your print statement is located. I don't know how you are running this, but I'm assuming you've updated your view code since the OP, or the generalized modifications you made for the post are masking what is actually happening.

-James

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2Be%2BciWhxN27evbqJsuiqS20sEh6J32RLPof4ww87JFwQh0dFQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment