Ticket #1305: bigwrite-twisted.py

File bigwrite-twisted.py, 1.9 KB (added by manlio, 9 years ago)
Line 
1"""Try to reproduce a bug with Twisted
2Manlio Perillo (manlio.perillo@gmail.com)
3
4This small code causes 2 bugs and 1 strange behaviour.
5
6Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32
7Twisted 2.0.1
8
9
101. set doCrash = 0 and doStrange = 1
11On my system I obtain:
12
13exceptions.IOError: [Errno 12] Not enough space
14
15well, this happens even without Twisted...
16it seems to be a Windows problem
17
182. set doCrash = 0 and doStrange = 0
19Now there is no exception...
20
21But when I hit Ctrl-C to stop program execution I obtain:
22Traceback (most recent call last):
23          File bigwrite-twisted.py, line 54, in ?
24            reactor.run()
25          File twisted\internet\posixbase.py, line 200, in run
26            self.mainLoop()
27          File twisted\internet\posixbase.py, line 208, in mainLoop
28            self.runUntilCurrent()
29        --- <exception caught here> ---
30          File twisted\internet\base.py, line 533, in runUntilCurrent
31            call.func(*call.args, **call.kw)
32          File twisted\internet\base.py, line 389, in _continueSystemEvent
33            for callList in sysEvtTriggers[1], sysEvtTriggers[2]:
34        exceptions.TypeError: unsubscriptable object
35
363. set doCrash = 1 and doStrange = 0
37Now Python crashes when trying to print the data...
38"""
39
40import sys
41
42from twisted.internet import reactor
43from twisted.python import log
44
45
46doCrash = 1
47doStrange = 0
48
49if doCrash:
50    N = 10000
51else:
52    N = 100
53
54def doBug():
55    data = 'bla bla' * N
56
57    if not doCrash:
58        data = '\n'.join([data] * N)
59   
60    d = {
61        1: [['DATA', ['XXX', 'YYY'], [data]]],
62        2: [['DATA', ['ZZZ', 'WWW'], [data]]]
63        }
64
65    print "data:", data
66    print "written"
67
68    reactor.stop()
69
70
71if not doStrange:
72    log.startLogging(sys.stdout)
73
74reactor.callLater(2, doBug)
75reactor.run()