Monday, May 30, 2016

Re: Simultaneous Web Requests appending responses in function based views

Hello James,
        Here below is my code:

qList in the code below, actually take a list of functions and uses the parameters received thru the request, processes and appends the response to 'p'. In this code, I eliminated those functions and hardcoded with a list of strings.

def search(request):

p = []
cd = {}
qList=[]
request_context = RequestContext(request)

if request_context.request.GET:
form = SearchForm(request_context.request.GET)
# print form
if form.is_valid():
cd = request_context.request.GET
projectId = cd['project']
app = cd['app']
if cd['days'] != '0':
daysAgo = '-' + cd['days']
else:
daysAgo = cd['days']
sdtime = cd['sdtime']
edtime = cd['edtime']

qList = ["Hello, I am X", "Hello, I am Y", "Hello, I am A", "Hello, I am B"]

for func in qList:
print func
t.sleep(10)
p.append(func)
context = {'query_output': p, 'id_project': projectId,
'app': app, 'pOutput': p}
return render(request, 'temp.html', context)

else:
form = SearchForm()
return render_to_response('search_form.html', {'form': form})

Thanks
crkatz

On Monday, May 30, 2016 at 2:10:17 AM UTC-4, James Schneider wrote:


On May 29, 2016 4:23 PM, "cr katz" <crka...@gmail.com> wrote:
>
> Hello,
>         I am new to django. I developed a web application using form based views. When I submit a single web request from the dev env, the response is returned correctly. When submit 2 simultaneously from 2 browsers, I see appended responses for each request. 
>
> How can I process requests independently?

That would certainly be odd behavior, although I'm not exactly sure what you mean. Can you post the output that you're seeing and the view in question?

-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/04067a15-d2cd-48d9-810c-8abe5760278c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment