我正在用扭曲的 python 看这个教程。 https://github.com/jdavisp3/twisted-intro/blob/master/twisted-client-3/get-poetry.py
def get_poetry(host, port, callback):
"""
Download a poem from the given host and port and invoke
callback(poem)
when the poem is complete.
"""
from twisted.internet import reactor
factory = PoetryClientFactory(callback)#I am interested in checking the instances alive here
reactor.connectTCP(host, port, factory)
def poetry_main():
addresses = parse_args()
from twisted.internet import reactor
poems = []
def got_poem(poem):
poems.append(poem)
if len(poems) == len(addresses):
reactor.stop()
for address in addresses:
host, port = address
get_poetry(host, port, got_poem)
reactor.run()
for poem in poems:
print poem
if __name__ == '__main__':
poetry_main()
我以前从未真正调试过python。
我想在 reactor.stop 触发之前查看哪些类的实例是活动的。
我正在检查这个打印一个类的所有实例
使用此代码
import gc
for obj in gc.get_objects():
我怎样才能有选择地查看最上面的信息,然后进一步继承数据等等?
从扭曲的角度来看,我想看看哪些工厂实例当前处于活动状态,以及它与协议有何关系