best method to set/unset environment variables

Hello
I have a python plugin of PluginType = Advanced. I need to setup job-specific environment variables, and after rendering, revert them to original state.
What would be the most bulletproof method to un-set variables? Right now I just do it at the end of RenderTasks() routine, but it often happens that the whole thing fails, and next task is inheriting modified envvars.
This is especially troublesome with $PATH, that grows with each task (I append to it), and in the end is too long, resulting in a mysterious ‘Word too long’ system error :slight_smile:
Is there a block of code that is quaranteed to be executed post-task ? Or maybe a better way of handlig job-specific envvars ?

thanks :slight_smile:
Michal

Hi Michal,

Just to confirm, do you need to set/unset the environment variables for each job, or for each task of a job? If it’s for each job, you could set them in StartJob() and unset them in EndJob().

Cheers,

  • Ryan