> I'm trying to do something similar to that poll_file.py does.
> I don't really understand how this example is supposed to work.
> In poll_file method, I added the line
> print 'file polled!'
> at the very beginning.
> I run poll_file.py and then, if I touch heart.vtk (touch unix command)
> no message is displayed.
> What am I doing wrong?
It doesn't work for me, either. At one time, I think I figured out why not, but all I can remember now is that it doesn't. For FiPy, I implemented a Mayavi Viewer based on poll_file.py, which you can find here:
There are a a lot of aspects to mayaviDaemon.py that are peculiar to our needs, but the only difference in the polling seems to be that I didn't use Pollster, but just have Timer call a poll_file method.
Ah, no, wait... I found the version of poll_file.py that I hacked to get things working. The problem is that timer is declared in the local scope of poll_file.py:main() at
and that as soon as the timer is declared it goes out of scope. My hack to poll_file.py was to add
mayavi.savedtimerbug = timer
in the next line so that the Timer() is not garbage collected.
In our own mayaviDaemon.py, I made the MayaviDaemon an instance of enthought.mayavi.plugins.app.Mayavi and moved the timer declaration to MayaviDaemon.__init__() and declared the timer as data member of the class, thus keeping everything in scope and the timer firing.