After further testing it turns out that Trap() have too many
implementation details which makes it cumbersome to be shared. Instead,
it's easier to make it into wrapper over shared functions.
Change-Id: I8a3c62bcdf4286f8127c5b6d8dee6d740aca23b9
d.addCallback(partial(handle_reply,self.transport.write,self.factory.log))# treq's collect helper is handy to get all reply content at once using closure on ctx
d.addErrback(lambdae,bsc:self.factory.log.critical("HTTP POST error %s while trying to register BSC %s on %s"%(e,bsc,self.factory.location)),bsc)# handle HTTP errors
# Ensure that we run only limited number of requests in parallel:
yieldself.factory.semaphore.acquire()
yieldd# we end up here only if semaphore is available which means it's ok to fire the request without exceeding the limit
d.addCallback(collect,partial(handle_reply,ctx.process_reply,self.transport.write,self.factory.log))# treq's collect helper is handy to get all reply content at once using closure on ctx
d.addErrback(lambdae,bsc:self.factory.log.critical("HTTP POST error %s while trying to register BSC %s on %s"%(e,bsc,self.factory.location)),bsc)# handle HTTP errors
# Ensure that we run only limited number of requests in parallel:
yieldself.factory.semaphore.acquire()
yieldd# we end up here only if semaphore is available which means it's ok to fire the request without exceeding the limit