File: testrpc.py

package info (click to toggle)
boa-constructor 0.3.0-3
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 8,188 kB
  • ctags: 8,857
  • sloc: python: 54,163; sh: 66; makefile: 36
file content (56 lines) | stat: -rw-r--r-- 1,398 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import os, sys
sys.path[0:0] = [os.pardir]

from ChildProcessClient import spawnChild
from wxPython.wx import wxProcess
from time import sleep
import threading

class Monitor:
    def isAlive(self):
        return 1
monitor = Monitor()


process = wxProcess()
process.Redirect()

def pollStreams():
    stream = process.GetInputStream()
    if not stream.eof():
        print '<<' + stream.read() + '>>'
    stream = process.GetErrorStream()
    if not stream.eof():
        print '<<<' + stream.read() + '>>>'

poll_streams = 1

def streamPollThread():
    while poll_streams:
        pollStreams()
        sleep(0.15)

print 'spawning...'
s, input, output, processId = spawnChild(monitor, process)

t = threading.Thread(target=streamPollThread)
t.setDaemon(1)
t.start()

print 'starting... (via %s)' % s
status = s.runFileAndRequestStatus('test.py', (), 0, (),
                                   ({'filename':'test.py',
                                     'lineno':15,
                                     'cond':'',
                                     'enabled':1,
                                     'temporary':0},
                                    ))
print status
print 'running...'
status = s.proceedAndRequestStatus('set_continue')
sleep(0.5)
print status
poll_streams = 0
sleep(0.3)

# Should stop in the middle of the process.