<div dir="ltr">Hi,<div><br></div><div>I have been submitting many patches to get buildbot working on Python 3:</div><div><br></div><div><a href="http://bit.ly/2jCCMPW">http://bit.ly/2jCCMPW</a><br></div><div><br></div><div>I have run into one problem involving inlineCallback, Deferred, and yield</div><div>which I am having difficulty solving.  Can someone help me?</div><div><br></div><div>If I do the following inside a Python 3 virtualenv to set things up:</div><div><br></div><div>git clone <a href="https://github.com/buildbot/buildbot">https://github.com/buildbot/buildbot</a> buildbot_test</div><div>cd buildbot_test</div><div>pip install -e pkg</div><div><span class="gmail-s1">pip install -e worker</span></div><div><span class="gmail-s2">pip</span><span class="gmail-s1"> install -e 'master[tls,tests]'</span></div><div><span class="gmail-s1">







<p class="gmail-p1"><span class="gmail-s1">trial </span>buildbot.test.unit.test_process_buildrequestdistributor</p></span></div><div>I get this error:</div><br>==================================================================<br>  File "/Users/crodrigues/buildbot_test/master/buildbot/process/buildrequestdistributor.py", line 93, in <lambda>^M<br>    brdicts.sort(key=lambda brd: brd['submitted_at'])<br>builtins.TypeError: 'Deferred' object is not subscriptable<br><br>buildbot.test.unit.test_process_buildrequestdistributor.TestMaybeStartBuilds.test_slow_db^M<div>==================================================================</div> <div><br></div><div>The code causing this problem is on line 93 of master/buildbot/process/buildrequestdistributor.py:</div>







<br> 78     @defer.inlineCallbacks<br> 79     def _fetchUnclaimedBrdicts(self):<br> 80         # Sets up a cache of all the unclaimed brdicts. The cache is<br> 81         # saved at self.unclaimedBrdicts cache. If the cache already<br> 82         # exists, this function does nothing. If a refetch is desired, set<br> 83         # the self.unclaimedBrdicts to None before calling."""<br> 84         if self.unclaimedBrdicts is None:<br> 85             # TODO: use order of the DATA API<br> 86             brdicts = yield self.master.data.get(('builders',<br> 87                                                   (yield self.bldr.getBuilderId()),<br> 88                                                   'buildrequests'),<br> 89                                                  [resultspec.Filter('claimed',<br> 90                                                                     'eq',<br> 91                                                                     [False])])<br> 92             # sort by submitted_at, so the first is the oldest<br> 93             brdicts.sort(key=lambda brd: brd['submitted_at'])<br> 94             self.unclaimedBrdicts = brdicts<br> 95         defer.returnValue(self.unclaimedBrdicts)<div><br></div><div>If I run the test on Python 2, I don't get the error, and on line 93, brdicts is a dict.</div><div>However, if I run the test on Python 3, brdicts is a Deferred, thus the error.</div><div><br></div><div>Can someone point me in the right direction for solving this problem?</div><div><br></div><div>I am not so familiar with the differences in generators and Deferreds between Python 2 and 3.</div><div><br></div><div>Thanks.</div><div><br></div><div>--</div><div>Craig</div></div>