1

Problem: Why can't I call others request

enter image description here

Goal: Wanted to call other services even if the previous one is still on process

enter image description here

I already tried this tornado-blocking-asynchronous-requests but still blocks the other request

Main handler

class Main(APIUserAuth):
    @gen.coroutine
        def post(self):
            hotelId=self.get_argument('code',False)
            try:
                if not hotelId:
                    raise Error('Hotel ID is not defined')
                params=escape.json_decode(self.request.body)
                result=yield Hotel.pricing(hotelId,params)
                self.write(result)
            except Error as e:
                self.write_wrong(str(e))
            except Exception as e:
                print(traceback.format_exc())
                self.write_wrong()
            finally:
                self.finish()

Hotel.py

@coroutine
def pricing(hotelId,request):
    params=parseParam(request)
    http_client=AsyncHTTPClient()
    url=URL+'/price'
    request=tornado.httpclient.HTTPRequest(url=url, method='POST',headers=HEADERS, body=json.dumps(params), connect_timeout=500, request_timeout=500)
    response= yield tornado.gen.Task(http_client.fetch, request)
    raise Return(response.body)

I wan't to call other request while the other 10 request are still on process. But why is that the other can still process the new request while the other is on process? Is having simultaneous 10 requests is too much to handle?

https://i.imgur.com/yVR8eNw.png

What might be the cause of this?

Jin Lee
  • 3,194
  • 12
  • 46
  • 86
Forbidden
  • 109
  • 2
  • 10
  • In that case I think the code is correctly non blocking. Where is the problem ? Also, you don't need to wrap your http request within a Task, you can yield it directly like this: `yield http_client.fetch(request)` – NicoAdrian Jul 14 '19 at 10:58
  • Right now, I still don't know why is the other requests blocks, other article says that its the browser limitation that a concurrent request on the same url will block the other request. – Forbidden Jul 16 '19 at 02:24

0 Answers0