/usr/lib/python2.7/dist-packages/rpy2/interactive/process_revents.py is in python-rpy2 2.8.5-1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 57 | """This module runs continuous updates for R, such as redrawing graphs when
the plot window is resized. Use the start() and stop() functions to turn
updates on and off.
"""
from rpy2.rinterface import process_revents
import time
import threading
class _EventProcessorThread(threading.Thread):
""" Call rinterface.process_revents(), pausing
for at least EventProcessor.interval between calls. """
_continue = True
def run(self):
while self._continue:
process_revents()
time.sleep(EventProcessor.interval)
class EventProcessor(object):
""" Processor for R events (Singleton class) """
interval = 0.2
daemon_thread = True
name_thread = 'rpy2_process_revents'
_thread = None
_instance = None
def __new__(cls):
if cls._instance is None:
cls._instance = object.__new__(cls)
return cls._instance
def start(self):
""" start the event processor """
if (self._thread is not None) and (self._thread.is_alive()):
raise RuntimeError("Processing of R events already started.")
else:
self._thread = _EventProcessorThread(name = self.name_thread)
self._thread.setDaemon(self.daemon_thread)
self._thread.start()
def stop(self):
""" stop the event processor """
self._thread._continue = False
self._thread.join()
thread = property(lambda self: self._thread,
None, None, "Thread that processes the events.")
def start():
""" Start the threaded processing of R events. """
EventProcessor().start()
def stop():
""" Stop the threaded processing of R events. """
EventProcessor().stop()
|