|
@@ -60,24 +60,23 @@ class RequestHandler(object):
|
|
|
|
|
|
# Append the server's replies to the list of replies.
|
|
|
if reply is not None:
|
|
|
- if self.generator_stack[-1]["replies"] is None:
|
|
|
- self.generator_stack[-1]["replies"] = reply
|
|
|
+ gen = self.generator_stack[-1]
|
|
|
+ if gen["replies"] is None:
|
|
|
+ gen["replies"] = reply
|
|
|
else:
|
|
|
- self.generator_stack[-1]["replies"].extend(reply)
|
|
|
+ gen["replies"].extend(reply)
|
|
|
|
|
|
while 1:
|
|
|
# Silence pylint's warning about catching Exception.
|
|
|
# pylint: disable=I0011,W0703
|
|
|
try:
|
|
|
- if self.generator_stack[-1]["finished_requests"]:
|
|
|
- gen = self.generator_stack[-1]
|
|
|
+ gen = self.generator_stack[-1]
|
|
|
+ if gen["finished_requests"]:
|
|
|
gen["pending_requests"] = gen["generator"].send(gen["replies"])
|
|
|
gen["finished_requests"] = False
|
|
|
gen["replies"] = None
|
|
|
return self.pop_requests()
|
|
|
|
|
|
- except primitive_functions.SleepKernel:
|
|
|
- raise
|
|
|
except KnownRequestHandled:
|
|
|
pass
|
|
|
except StopIteration:
|
|
@@ -100,6 +99,8 @@ class RequestHandler(object):
|
|
|
else:
|
|
|
# Looks like we're done here.
|
|
|
return None
|
|
|
+ except primitive_functions.SleepKernel:
|
|
|
+ raise
|
|
|
except Exception as ex:
|
|
|
# Maybe get an exception handler to do this.
|
|
|
stack_trace = self.handle_exception(ex)
|
|
@@ -124,7 +125,8 @@ class RequestHandler(object):
|
|
|
def pop_generator(self):
|
|
|
"""Removes the top-of-stack generator from the generator stack."""
|
|
|
# Pop the generator itself.
|
|
|
- self.generator_stack.pop()
|
|
|
+ #self.generator_stack.pop()
|
|
|
+ del self.generator_stack[-1]
|
|
|
# print('Popped generator %s. Generator count: %d' % (gen, len(self.generator_stack)))
|
|
|
# Pop any exception handlers defined by the generator.
|
|
|
top_of_stack_index = len(self.generator_stack)
|
|
@@ -133,7 +135,8 @@ class RequestHandler(object):
|
|
|
# Pop exception handlers until exception_handlers is empty or until
|
|
|
# we find an exception handler that is not associated with the popped
|
|
|
# generator.
|
|
|
- self.exception_handlers.pop()
|
|
|
+ #self.exception_handlers.pop()
|
|
|
+ del self.exception_handlers[-1]
|
|
|
else:
|
|
|
# We're done here.
|
|
|
break
|
|
@@ -224,7 +227,9 @@ class RequestHandler(object):
|
|
|
if requests:
|
|
|
if requests[0][0] in self.handlers:
|
|
|
# First element is a known request
|
|
|
- elem = requests.pop(0)
|
|
|
+ #elem = requests.pop(0)
|
|
|
+ elem = requests[0]
|
|
|
+ del requests[0]
|
|
|
|
|
|
# The list of requests might be empty now. If so, then flag this
|
|
|
# batch of requests as finished.
|