HenrikBengtsson / R.utils

🔧 R package: R.utils (this is *not* the utils package that comes with R itself)
https://henrikbengtsson.github.io/R.utils/
62 stars 14 forks source link

withTimeout() fails if the call that times out temporarily sets another language #140

Closed HenrikBengtsson closed 2 years ago

HenrikBengtsson commented 2 years ago

Issue

At least on MS Windows and macOS, withTimeout() fail if the call that times out temporarily sets another language, e.g.

R.utils::withTimeout({ 
  Sys.setenv(LANGUAGE='fr')
  on.exit(Sys.unsetenv("LANGUAGE"))
  repeat Sys.sleep(0.1) 
}, timeout = 0.5, onTimeout = 'silent')
#> Error in Sys.sleep(0.1) : la limite de temps est atteinte

I've added a package test for this (commit https://github.com/HenrikBengtsson/R.utils/commit/c4fd62ecac3c233d7d92e57ee813b0e11aa3f1dd) and it turns out that this happens on MS Windows and macOS, but not Linux, cf. https://github.com/HenrikBengtsson/R.utils/actions/runs/3308331545.

Action

I'm not sure if this can be fixed. I doubt withTimeout() can identify the language that was set temporarily, which means we cannot parse the captured error message and identify it as a timeout error message.

Related

This was related to Issue #133, but most likely not the same problem.

HenrikBengtsson commented 2 years ago

Added Section 'Known limitation: May fail when temporarily switching language' to ?withTimeout.