0
我有一個類,它被註釋爲@ defer.inlineCallbacks (我想返回從這個機器列表)如何從Python中的延遲方法/扭曲的分配返回值
@defer.inlineCallbacks
def getMachines(self):
serverip = 'xx'
basedn = 'xx'
binddn = 'xx'
bindpw = 'xx'
query = '(&(cn=xx*)(objectClass=computer))'
c = ldapconnector.LDAPClientCreator(reactor, ldapclient.LDAPClient)
overrides = {basedn: (serverip, 389)}
client = yield c.connect(basedn, overrides=overrides)
yield client.bind(binddn, bindpw)
o = ldapsyntax.LDAPEntry(client, basedn)
results = yield o.search(filterText=query)
for entry in results:
for i in entry.get('name'):
self.machineList.append(i)
yield self.machineList
return
我在另一個python文件中定義另一個類,在那裏我要調用上面的方法並讀取machineList。
returned = LdapClass().getMachines()
print returned
打印說<Deferred at 0x10f982908>
。我如何閱讀清單?