Mercurial > pydertron
changeset 19:2dc43c316df9
Added opcb parameter
author | Atul Varma <varmaa@toolness.com> |
---|---|
date | Thu, 10 Sep 2009 15:13:33 -0700 |
parents | 9fe3f115f951 |
children | d382ca63d43f |
files | pydertron.py |
diffstat | 1 files changed, 5 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/pydertron.py Thu Sep 10 14:58:00 2009 -0700 +++ b/pydertron.py Thu Sep 10 15:13:33 2009 -0700 @@ -280,7 +280,7 @@ loading and executing scripts. """ - def __init__(self, fs, watchdog=watchdog): + def __init__(self, fs, watchdog=watchdog, opcb=None): rt = pydermonkey.Runtime() cx = rt.new_context() root_proto = cx.new_object() @@ -292,6 +292,7 @@ watchdog.add_context(cx) self.fs = fs + self.opcb = opcb self.rt = rt self.cx = cx self.curr_exc = None @@ -333,9 +334,10 @@ del self.rt def _opcb(self, cx): - # Don't do anything; if a keyboard interrupt was triggered, + # Note that if a keyboard interrupt was triggered, # it'll get raised here automatically. - pass + if self.opcb: + self.opcb() def _throwhook(self, cx): curr_exc = cx.get_pending_exception()