diff options
author | pjenvey <devnull@localhost> | 2008-10-21 18:57:40 +0000 |
---|---|---|
committer | pjenvey <devnull@localhost> | 2008-10-21 18:57:40 +0000 |
commit | d31da69268777a8d355ef909da958caab987b09d (patch) | |
tree | 141e321335075c904ff5cebd652c33f29291e21d | |
parent | ee08be4e7794068c556b83c33588f8d65c3db5da (diff) | |
download | paste-d31da69268777a8d355ef909da958caab987b09d.tar.gz |
only expose JythonMonitor if on Jython and _systemrestart is supported
-rw-r--r-- | paste/reloader.py | 45 |
1 files changed, 23 insertions, 22 deletions
diff --git a/paste/reloader.py b/paste/reloader.py index 57915d5..67f704a 100644 --- a/paste/reloader.py +++ b/paste/reloader.py @@ -148,33 +148,34 @@ class Monitor(object): add_file_callback = classinstancemethod(add_file_callback) -class JythonMonitor(Monitor): +if sys.platform.startswith('java'): + try: + from _systemrestart import SystemRestart + except ImportError: + pass + else: + class JythonMonitor(Monitor): - """ - Monitor that utilizes Jython's special - ``_systemrestart.SystemRestart`` exception. + """ + Monitor that utilizes Jython's special + ``_systemrestart.SystemRestart`` exception. - When raised from the main thread it causes Jython to reload the - interpreter in the existing Java process (avoiding startup time). + When raised from the main thread it causes Jython to reload + the interpreter in the existing Java process (avoiding + startup time). - Note that this functionality of Jython is experimental and may - change in the future. - """ + Note that this functionality of Jython is experimental and + may change in the future. + """ - def __init__(self, *args, **kwargs): - Monitor.__init__(self, *args, **kwargs) + def __init__(self, *args, **kwargs): + Monitor.__init__(self, *args, **kwargs) - def periodic_reload(self): - while True: - if not self.check_reload(): - raise SystemRestart() - time.sleep(self.poll_interval) + def periodic_reload(self): + while True: + if not self.check_reload(): + raise SystemRestart() + time.sleep(self.poll_interval) -if sys.platform.startswith('java'): - try: - from _systemrestart import SystemRestart - except ImportError: - del JythonMonitor - watch_file = Monitor.watch_file add_file_callback = Monitor.add_file_callback |