在一个twisted python示例中,是否跳出whiletrue?

2024-04-29 13:23:35 发布

您现在位置:Python中文网/ 问答频道 /正文

当我执行以下操作时:

count = 0
while True: 
    count += 1
    try: 
        print count 
    except IOError:
        print 'cannot open'

这将打印0、1、2等。。一如预期。{1}虽然在下面的示例中执行了^ twisted,但仍中断了^执行的python循环。我错过了什么吗?在

^{pr2}$

打印如下:

('bytesread read: ', 'The Fascin')
('count read: ', 1)
('task? : ', 'The Fascin')
Task 2: got 10 bytes of poetry from 127.0.0.1:10001
('bytesread read: ', 'The Ecstasy\n\nWhere, like a pil')
('count read: ', 1)
('task? : ', 'The Ecstasy\n\nWhere, like a pil')
Task 1: got 30 bytes of poetry from 127.0.0.1:10000
('bytesread read: ', 'Sonnet - T')
('count read: ', 1)
('task? : ', 'Sonnet - T')
Task 3: got 10 bytes of poetry from 127.0.0.1:10002
('bytesread read: ', 'low on a bed\n         A pregna')
('count read: ', 1)
('task? : ', 'low on a bed\n         A pregna')
Task 1: got 30 bytes of poetry from 127.0.0.1:10000
('bytesread read: ', 'ation of w')
('count read: ', 1)
('task? : ', 'ation of w')
Task 2: got 10 bytes of poetry from 127.0.0.1:10001
('bytesread read: ', 'o Science\n')
('count read: ', 1)
('task? : ', 'o Science\n')
Task 3: got 10 bytes of poetry from 127.0.0.1:10002
('bytesread read: ', "nt bank swell'd up to rest\nThe")
('count read: ', 1)

Tags: ofthefromtaskreadpoetrybytescount