@@ -44,8 +44,9 @@ def complete(self, task_token,
4444 def poll (self , task_list = None ,
4545 identity = None ,
4646 ** kwargs ):
47- """Polls for decision tasks to process from current
48- actor's instance defined ``task_list``
47+ """
48+ Polls a decision task and returns the token and the full history of the
49+ workflow's events.
4950
5051 :param task_list: task list to poll for decision tasks from.
5152 :type task_list: string
@@ -55,22 +56,41 @@ def poll(self, task_list=None,
5556 workflow history.
5657 :type identity: string
5758
58- :returns: polled decision tasks
59+ :returns: (token, history)
5960 :type: swf.models.History
61+
6062 """
6163 task_list = task_list or self .task_list
6264
63- events = self .connection .poll_for_decision_task (
65+ task = self .connection .poll_for_decision_task (
6466 self .domain .name ,
6567 task_list = task_list ,
6668 identity = identity ,
6769 ** kwargs
6870 )
69-
70- if not 'taskToken' in events :
71+ token = task . get ( 'taskToken' )
72+ if token is None :
7173 raise PollTimeout ("Decider poll timed out" )
7274
73- history = History .from_event_list (events ['events' ])
74- task_token = events ['taskToken' ]
75+ events = task ['events' ]
76+
77+ next_page = task .get ('nextPageToken' )
78+ while next_page :
79+ task = self .connection .poll_for_decision_task (
80+ self .domain .name ,
81+ task_list = task_list ,
82+ identity = identity ,
83+ next_page_token = next_page ,
84+ ** kwargs
85+ )
86+
87+ token = task .get ('taskToken' )
88+ if token is None :
89+ raise PollTimeout ("Decider poll timed out" )
90+
91+ events .extend (task ['events' ])
92+ next_page = task .get ('nextPageToken' )
93+
94+ history = History .from_event_list (events )
7595
76- return task_token , history
96+ return token , history
0 commit comments