kabouzeid / turm

TUI for the Slurm Workload Manager
https://crates.io/crates/turm
MIT License
121 stars 4 forks source link

Fallback on `PollWatcher` #18

Open evanr70 opened 1 year ago

evanr70 commented 1 year ago

Users may not have control over the max watches limit of the recommended_watcher. In this case, it is desirable to fallback to the PollWatcher implementation which is x-platform as far as I can tell and shouldn't experience the same restriction.

To check if the watcher limit has been reached, we create a NamedTempFile using tempfile and check the result of watcher.watch on the recommended_watcher.

I've also removed some unwraps which were causing problems. Some are replaced with match blocks, others with bindings. I can't see any immediate problems from this, but it might be worth checking it out.

The checking code might be better off in a separate function which returns a Box<dyn Watcher> so can do that if you'd prefer.