[pypy-svn] r41675 - in pypy/build/buildtool: . bin testproject/bin web web/test
guido at codespeak.net
guido at codespeak.net
Fri Mar 30 12:40:18 CEST 2007
Author: guido
Date: Fri Mar 30 12:40:13 2007
New Revision: 41675
Modified:
pypy/build/buildtool/bin/buildserver.py
pypy/build/buildtool/bin/removebuild.py
pypy/build/buildtool/bin/webserver
pypy/build/buildtool/metaserver.py
pypy/build/buildtool/testproject/bin/buildserver.py
pypy/build/buildtool/testproject/bin/startcompile.py
pypy/build/buildtool/web/app.py
pypy/build/buildtool/web/test/test_app.py
Log:
More shutdown/cleanup fixes.
Modified: pypy/build/buildtool/bin/buildserver.py
==============================================================================
--- pypy/build/buildtool/bin/buildserver.py (original)
+++ pypy/build/buildtool/bin/buildserver.py Fri Mar 30 12:40:13 2007
@@ -77,18 +77,23 @@
channel.close()
"""
gw = PopenGateway()
- interpolated = py.code.Source(outputbuffer,
- code % (str(wc), config.path,
- compileinfo, str(buildpath)))
- channel = gw.remote_exec(interpolated)
try:
- upath = channel.receive()
- output = channel.receive()
- except channel.RemoteError, e:
- print 'Remote exception:'
- print str(e)
- return (None, str(e))
- channel.close()
+ interpolated = py.code.Source(outputbuffer,
+ code % (str(wc), config.path,
+ compileinfo, str(buildpath)))
+ channel = gw.remote_exec(interpolated)
+ try:
+ try:
+ upath = channel.receive()
+ output = channel.receive()
+ except channel.RemoteError, e:
+ print 'Remote exception:'
+ print str(e)
+ return (None, str(e))
+ finally:
+ channel.close()
+ finally:
+ gw.exit()
return upath, output
Modified: pypy/build/buildtool/bin/removebuild.py
==============================================================================
--- pypy/build/buildtool/bin/removebuild.py (original)
+++ pypy/build/buildtool/bin/removebuild.py Fri Mar 30 12:40:13 2007
@@ -46,7 +46,10 @@
def removebuild(id, gw, port, path):
conference = execnetconference.conference(gw, port, False)
channel = conference.remote_exec(code % (path, id))
- return channel.receive()
+ try:
+ return channel.receive()
+ finally:
+ channel.close()
if __name__ == '__main__':
import sys
@@ -59,4 +62,7 @@
gw = PopenGateway()
else:
gw = SshGateway(config.server)
- print removebuild(sys.argv[1], gw, config.port, config.path)
+ try:
+ print removebuild(sys.argv[1], gw, config.port, config.path)
+ finally:
+ gw.exit()
Modified: pypy/build/buildtool/bin/webserver
==============================================================================
--- pypy/build/buildtool/bin/webserver (original)
+++ pypy/build/buildtool/bin/webserver Fri Mar 30 12:40:13 2007
@@ -5,9 +5,9 @@
from buildtool import config
if __name__ == '__main__':
- from py.execnet import SshGateway, PopenGateway
from buildtool.web.server import run_server
from buildtool.web.app import AppHandler
- print 'starting server at port (%r, %r)' % (config.webserver, config.webport)
+ print 'starting server at port (%r, %r)' % (config.webserver,
+ config.webport)
run_server((config.webserver, config.webport), AppHandler)
Modified: pypy/build/buildtool/metaserver.py
==============================================================================
--- pypy/build/buildtool/metaserver.py (original)
+++ pypy/build/buildtool/metaserver.py Fri Mar 30 12:40:13 2007
@@ -344,27 +344,29 @@
gw = PopenGateway()
else:
gw = SshGateway(config.server)
- channel = init(gw, config)
+ try:
+ channel = init(gw, config)
+ try:
- def main():
- while 1:
- try:
- data = channel.receive()
- except EOFError:
- break
- else:
- print data
+ def main():
+ while 1:
+ try:
+ data = channel.receive()
+ except EOFError:
+ break
+ else:
+ print data
- thread.start_new_thread(main, ())
+ thread.start_new_thread(main, ())
- try:
- try:
- while 1:
- channel.send(None) # ping
- time.sleep(1)
- except (SystemExit, KeyboardInterrupt):
- channel.send('quit')
+ try:
+ while 1:
+ channel.send(None) # ping
+ time.sleep(1)
+ except (SystemExit, KeyboardInterrupt):
+ channel.send('quit')
+ finally:
+ channel.close()
finally:
- channel.close()
gw.exit()
Modified: pypy/build/buildtool/testproject/bin/buildserver.py
==============================================================================
--- pypy/build/buildtool/testproject/bin/buildserver.py (original)
+++ pypy/build/buildtool/testproject/bin/buildserver.py Fri Mar 30 12:40:13 2007
@@ -29,16 +29,19 @@
channel.close()
"""
gw = PopenGateway()
- interpolated = py.code.Source(outputbuffer, code % (str(wc),))
- channel = gw.remote_exec(interpolated)
try:
- upath = channel.receive()
- output = channel.receive()
- except channel.RemoteError, e:
- print 'Remote exception:'
- print str(e)
- return (None, str(e))
- channel.close()
+ interpolated = py.code.Source(outputbuffer, code % (str(wc),))
+ channel = gw.remote_exec(interpolated)
+ try:
+ upath = channel.receive()
+ output = channel.receive()
+ except channel.RemoteError, e:
+ print 'Remote exception:'
+ print str(e)
+ return (None, str(e))
+ channel.close()
+ finally:
+ gw.exit()
return upath, output
Modified: pypy/build/buildtool/testproject/bin/startcompile.py
==============================================================================
--- pypy/build/buildtool/testproject/bin/startcompile.py (original)
+++ pypy/build/buildtool/testproject/bin/startcompile.py Fri Mar 30 12:40:13 2007
@@ -3,7 +3,6 @@
import autopath
from buildtool.testproject import config
from buildtool.compile import main, getrequest
-from py.execnet import SshGateway, PopenGateway
request, foreground = getrequest(config)
main(config, request, foreground)
Modified: pypy/build/buildtool/web/app.py
==============================================================================
--- pypy/build/buildtool/web/app.py (original)
+++ pypy/build/buildtool/web/app.py Fri Mar 30 12:40:13 2007
@@ -4,6 +4,8 @@
import py
import time
+import signal
+import sys
from buildtool import config
from buildtool import execnetconference
from buildtool.build import BuildRequest
@@ -504,6 +506,16 @@
info.update({'status': status})
return info
+def cleanup_shared(*args, **kwargs):
+ if ServerPage._shared['initialized']:
+ ServerPage._shared['channel'].close()
+ ServerPage._shared['gateway'].exit()
+ print 'closed server'
+ sys.exit(0)
+
+signal.signal(signal.SIGHUP, cleanup_shared)
+signal.signal(signal.SIGINT, cleanup_shared)
+
if __name__ == '__main__':
from buildtool.web.server import run_server
run_server(('', 8080), AppHandler)
Modified: pypy/build/buildtool/web/test/test_app.py
==============================================================================
--- pypy/build/buildtool/web/test/test_app.py (original)
+++ pypy/build/buildtool/web/test/test_app.py Fri Mar 30 12:40:13 2007
@@ -63,17 +63,19 @@
conference = execnetconference.conference(gw, port, True)
channel = conference.remote_exec(_metaserver_init % (path,))
channel.receive()
- return channel
+ return gw, channel
def setup_module(mod):
mod.path = path = packageparent.strpath
- mod.server_channel = init_fake_metaserver(TESTPORT, [path])
+ mod.server_gw, mod.server_channel = init_fake_metaserver(TESTPORT, [path])
mod.config = fake.Container(port=TESTPORT, path=path, server='localhost')
mod.gateway = py.execnet.PopenGateway()
ServerPage.MAX_CACHE_TIME = -1
def teardown_module(mod):
mod.server_channel.send('quit')
+ mod.server_channel.close()
+ mod.server_gateway.exit()
mod.gateway.exit()
class TestIndexPage(object):
More information about the Pypy-commit
mailing list