mirror of
https://github.com/avatao-content/baseimage-tutorial-framework
synced 2024-12-22 17:11:56 +00:00
Fix handling exhausted generators
This commit is contained in:
parent
ad89c8fb57
commit
92394cac27
@ -71,7 +71,6 @@ def login_handler(data, component):
|
||||
|
||||
|
||||
def source_code_handler(data, event_handler):
|
||||
event_handler.unsubscribe(data['anchor'])
|
||||
yield (data['anchor'],
|
||||
source_code.get_source_code(authorize_login, strip_comments=True))
|
||||
|
||||
|
@ -21,7 +21,11 @@ class StatefulEventHandler(EventHandlerBase):
|
||||
data_json = json.loads(message)
|
||||
if self.generator is None:
|
||||
self.generator = self.event_handler_function(data_json, self)
|
||||
response_anchor, response_data = next(self.generator)
|
||||
try:
|
||||
response_anchor, response_data = next(self.generator)
|
||||
except StopIteration:
|
||||
self.reset()
|
||||
return
|
||||
if response_anchor not in self.subscriptions:
|
||||
self.subscriptions.add(response_anchor)
|
||||
self.zmq_sub_socket.setsockopt_string(zmq.SUBSCRIBE, response_anchor)
|
||||
|
Loading…
Reference in New Issue
Block a user