Mercurial > sjsbox
changeset 9:fb7ca2688d3d
disabled resource limits, added timeout on message passing
author | Atul Varma <avarma@mozilla.com> |
---|---|
date | Mon, 31 May 2010 12:34:33 -0700 |
parents | 0efba0cf0ca3 |
children | 479e73ddf945 |
files | sjsbox/box.py |
diffstat | 1 files changed, 17 insertions(+), 10 deletions(-) [+] |
line wrap: on
line diff
--- a/sjsbox/box.py Mon May 31 12:18:28 2010 -0700 +++ b/sjsbox/box.py Mon May 31 12:34:33 2010 -0700 @@ -4,12 +4,12 @@ class BoxChild(object): LIMITS = { - resource.RLIMIT_DATA: (1024 * 1024, 1024 * 2048), - resource.RLIMIT_STACK: (1024 * 512, 1024 * 1024), - resource.RLIMIT_RSS: (1024 * 1024, 1024 * 2048), - resource.RLIMIT_AS: (1024 * 1024, 1024 * 2048), - resource.RLIMIT_CPU: (5, 10), - resource.RLIMIT_NOFILE: (10, 20) + #resource.RLIMIT_DATA: (1024 * 1024, 1024 * 2048), + #resource.RLIMIT_STACK: (1024 * 512, 1024 * 1024), + #resource.RLIMIT_RSS: (1024 * 1024, 1024 * 2048), + #resource.RLIMIT_AS: (1024 * 1024, 1024 * 2048), + #resource.RLIMIT_CPU: (5, 10), + #resource.RLIMIT_NOFILE: (10, 20) } def __init__(self, f, pipe): @@ -63,14 +63,21 @@ kwargs=kwargs) self.child.start() + def __child_call(self, msg, *args): + if self.child is None: + raise IOError('process is shut down') + self.child_pipe.send((msg, args)) + if not self.child_pipe.poll(self.TIMEOUT): + self.shutdown() + raise IOError('message send failed: %s' % msg) + return self.child_pipe.recv() + def handle(self, method, path): - self.child_pipe.send(('handle', (method, path))) - return self.child_pipe.recv() + return self.__child_call('handle', method, path) @property def status(self): - self.child_pipe.send(('status', ())) - return self.child_pipe.recv() + return self.__child_call('status') def shutdown(self): self.child_pipe.send(('shutdown', None))