<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Sat, Jan 21, 2017 at 8:06 PM, Glyph Lefkowitz <span dir="ltr"><<a href="mailto:glyph@twistedmatrix.com" target="_blank">glyph@twistedmatrix.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div style="word-wrap:break-word"><span class="gmail-"><br><div><blockquote type="cite"><div>On Jan 21, 2017, at 6:15 PM, Craig Rodrigues <<a href="mailto:rodrigc@crodrigues.org" target="_blank">rodrigc@crodrigues.org</a>> wrote:</div><br class="gmail-m_1103198121470315311Apple-interchange-newline"><div><div style="font-family:menlo-regular;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">If I run the test on Python 2, I don't get the error, and on line 93, brdicts is a dict.</div><div style="font-family:menlo-regular;font-size:12px;font-style:normal;font-variant-caps:normal;font-weight:normal;letter-spacing:normal;text-align:start;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px">However, if I run the test on Python 3, brdicts is a Deferred, thus the error.</div></div></blockquote><br></div></span><div>This really ought to be impossible. If I were seeing this, single-stepping through inlineCallbacks in pudb would probably be my next step. Have you made any attempts to simplify it down to remove some of the buildbot-specific code?</div><span class="gmail-HOEnZb"><font color="#888888"><br><div>-glyph</div></font></span></div><br></blockquote><div><br></div><div><br></div>I did some more debugging. The callstack is quite deep. :/<br>I used this command to trigger the error:<br><br>trial buildbot.test.unit.test_process_buildrequestdistributor.TestMaybeStartBuilds.test_slow_db<br><br>I found in this function in buildbot's BuildRequestsEndpoint.get() function ( <a href="https://github.com/buildbot/buildbot/blob/master/master/buildbot/data/buildrequests.py#L146">https://github.com/buildbot/buildbot/blob/master/master/buildbot/data/buildrequests.py#L146</a> ) there is this line:<br><br><b> defer.returnValue(<br> [(yield self.db2data(br)) for br in buildrequests])<br></b><br>On Python 2, this line returns:</div><div class="gmail_quote"> an object list</div><div class="gmail_quote"> each list entry is a dictionary of name/value pairs that looks like:</div><div class="gmail_quote">
<p class="gmail-p1"><span class="gmail-s1">[{'buildrequestid': 10, 'complete': False, 'waited_for': False, 'claimed_at': None, 'results': -1, 'claimed': False, 'buildsetid': 11, 'complete_at': None, 'submitted_at': datetime.datetime(1970, 1, 2, 12, 6, 40, tzinfo=tzutc()), 'builderid': 77, 'claimed_by_masterid': None, 'priority': 0}, {'buildrequestid': 11, 'complete': False, 'waited_for': False, 'claimed_at': None, 'results': -1, 'claimed': False, 'buildsetid': 11, 'complete_at': None, 'submitted_at': datetime.datetime(1970, 1, 2, 13, 30, tzinfo=tzutc()), 'builderid': 77, 'claimed_by_masterid': None, 'priority': 0}]</span></p></div><div class="gmail_quote"><br></div><div class="gmail_quote">On Python 3, this returns:</div><div class="gmail_quote"> an object <generator object BuildRequestsEndpoint.get.<locals>.<listcomp></div><div class="gmail_quote"> of type <class 'generator'><br><br></div><div class="gmail_quote">The self.db2data() function returns defer.succeed(data) ( <a href="https://github.com/buildbot/buildbot/blob/master/master/buildbot/data/buildrequests.py#L32">https://github.com/buildbot/buildbot/blob/master/master/buildbot/data/buildrequests.py#L32</a> )</div><div class="gmail_quote"><br></div><div class="gmail_quote">So it looks like on Python 3, this is not getting evaluated properly, and the upper layer is trying</div><div class="gmail_quote">to index a Deferred instead of a list of dictionaries.</div><div class="gmail_quote"><br></div><div class="gmail_quote">I'm not so familiar with generators/Deferreds in Py2 vs. Py3. What is the best way</div><div class="gmail_quote">to fix this to get consistent behavior on Py2 and Py3?</div><div class="gmail_quote"><br></div><div class="gmail_quote">Thanks.</div><div class="gmail_quote">--</div><div class="gmail_quote">Craig</div></div></div>