| 1 | """Try to reproduce a bug with Twisted |
|---|
| 2 | Manlio Perillo (manlio.perillo@gmail.com) |
|---|
| 3 | |
|---|
| 4 | This small code causes 2 bugs and 1 strange behaviour. |
|---|
| 5 | |
|---|
| 6 | Python 2.4.1 (#65, Mar 30 2005, 09:13:57) [MSC v.1310 32 bit (Intel)] on win32 |
|---|
| 7 | Twisted 2.0.1 |
|---|
| 8 | |
|---|
| 9 | |
|---|
| 10 | 1. set doCrash = 0 and doStrange = 1 |
|---|
| 11 | On my system I obtain: |
|---|
| 12 | |
|---|
| 13 | exceptions.IOError: [Errno 12] Not enough space |
|---|
| 14 | |
|---|
| 15 | well, this happens even without Twisted... |
|---|
| 16 | it seems to be a Windows problem |
|---|
| 17 | |
|---|
| 18 | 2. set doCrash = 0 and doStrange = 0 |
|---|
| 19 | Now there is no exception... |
|---|
| 20 | |
|---|
| 21 | But when I hit Ctrl-C to stop program execution I obtain: |
|---|
| 22 | Traceback (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 | |
|---|
| 36 | 3. set doCrash = 1 and doStrange = 0 |
|---|
| 37 | Now Python crashes when trying to print the data... |
|---|
| 38 | """ |
|---|
| 39 | |
|---|
| 40 | import sys |
|---|
| 41 | |
|---|
| 42 | from twisted.internet import reactor |
|---|
| 43 | from twisted.python import log |
|---|
| 44 | |
|---|
| 45 | |
|---|
| 46 | doCrash = 1 |
|---|
| 47 | doStrange = 0 |
|---|
| 48 | |
|---|
| 49 | if doCrash: |
|---|
| 50 | N = 10000 |
|---|
| 51 | else: |
|---|
| 52 | N = 100 |
|---|
| 53 | |
|---|
| 54 | def 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 | |
|---|
| 71 | if not doStrange: |
|---|
| 72 | log.startLogging(sys.stdout) |
|---|
| 73 | |
|---|
| 74 | reactor.callLater(2, doBug) |
|---|
| 75 | reactor.run() |
|---|