On Tue, 19 May 2020 12:01:54 -0400, David Storrs
<david.sto...@gmail.com> wrote:

>I'm using the file-watchers module to keep an eye on a directory tree and
>trigger various actions whenever something changes.  I had an issue where
>an exception was thrown, the thread died, and file watching therefore
>stopped.  The immediate solution is to wrap a with-handlers around it so it
>doesn't end up killing the thread, but this made me wonder if there's an
>easy way to do this automatically?
>
>What I'm thinking of is "Create a thread that will do something in a loop.
>Ensure that the thread remains running and restart it if it dies for any
>reason.  Also, make sure that it runs periodically."  I can think of a
>solution involving multiple threads, channels, and polling to ensure that
>the 'daemonized' threads are running, but I was wondering if there's a
>built-in or existing answer.

There is a package called "thread-utils" which claims error safe
looping threads.
https://pkgs.racket-lang.org/package/thread-utils

*Disclaimer*  I have never tried it.


I can think of a some possible implementations, but they all involve
monitoring by a separate thread (which could be the main thread).
Channels aren't necessary - monitoring can be done using events.

Restarting a (possibly failed) computation IN a running thread is
relatively simple - if you know what errors or events might occur. The
problem is that a thread can't restart itself if somehow it gets
suspended or killed.

George

-- 
You received this message because you are subscribed to the Google Groups 
"Racket Users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to racket-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/racket-users/uvi8cftuuvfkq0cqm27m0icvhhq5mpupuo%404ax.com.

Reply via email to