Unable to modify worker's environment within EventPlugin

Hello,

I’ve written an event plugin that runs on the OnSlaveRendering callback.
The plugin applies path remapping to certain environment variables and then saves them to be used in the rendering process.
I’ve tried both self.SetProcessEnvironmentVariable() and setting in os.environ however when the render plugin process starts and I print the variables, they are unmodified.
The render plugin is using rez if that changes anything.

Event Plugin log:

2023-12-20 15:53:18:  INFO: Event Plugin Remap_Paths OnJobStarted started
2023-12-20 15:53:18:  INFO: keys to remap: PXR_AR_DEFAULT_SEARCH_PATH
2023-12-20 15:53:18:  EnvRemapper: value is:  C:\PROGRA~1\SIDEEF~1\HOUDIN~1.547;E:\Projects\RockinVFX\25_FHTG2
2023-12-20 15:53:18:  CheckPathMapping: Swapped "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.547;E:\Projects\RockinVFX\25_FHTG2" with "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.547;%RVFX_ROOT%\25_FHTG2"
2023-12-20 15:53:18:  CheckPathMapping: Swapped "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.547;%RVFX_ROOT%\25_FHTG2" with "C:\PROGRA~1\SIDEEF~1\HOUDIN~1.547;D:\Projets\25_FHTG2"
2023-12-20 15:53:18:  EnvRemapper: converted value is:  C:/PROGRA~1/SIDEEF~1/HOUDIN~1.547;D:/Projets/25_FHTG2
2023-12-20 15:53:18:  EnvRemapper: Setting Process Environment Variable PXR_AR_DEFAULT_SEARCH_PATH to C:/PROGRA~1/SIDEEF~1/HOUDIN~1.547;D:/Projets/25_FHTG2
2023-12-20 15:53:18:  INFO: Path Mapping VAR: PXR_AR_DEFAULT_SEARCH_PATH from C:\PROGRA~1\SIDEEF~1\HOUDIN~1.547;E:\Projects\RockinVFX\25_FHTG2 to C:/PROGRA~1/SIDEEF~1/HOUDIN~1.547;D:/Projets/25_FHTG2
2023-12-20 15:53:18:  INFO: Done EnvRemapper

Render Plugin log:

2023-12-20 15:53:18:  0: Start Job timeout is disabled.
2023-12-20 15:53:18:  0: Task timeout is 10800 seconds (Regular Task Timeout)
2023-12-20 15:53:18:  0: Plugin rendering frame(s): 1081
2023-12-20 15:53:19:  0: Executing plugin command of type 'Render Task'
2023-12-20 15:53:19:  0: INFO: Stdout Redirection Enabled: True
2023-12-20 15:53:19:  0: INFO: Stdout Handling Enabled: True
2023-12-20 15:53:19:  0: INFO: Popup Handling Enabled: False
2023-12-20 15:53:19:  0: INFO: Using Process Tree: True
2023-12-20 15:53:19:  0: INFO: Hiding DOS Window: True
2023-12-20 15:53:19:  0: INFO: Creating New Console: False
2023-12-20 15:53:19:  0: INFO: Running as user: Damien
2023-12-20 15:53:19:  0: INFO: File "rez.exe" is not rooted, checking current directory
2023-12-20 15:53:19:  0: INFO: File "rez.exe" is not rooted and is not in the current directory, checking PATH
2023-12-20 15:53:19:  0: INFO: Executable: "C:\rez\Scripts\rez\rez.exe"
2023-12-20 15:53:19:  0: PYTHON: found search path as C:/PROGRA~1/SIDEEF~1/HOUDIN~1.547;E:/Projects/RockinVFX/25_FHTG2
2023-12-20 15:53:19:  0: PYTHON: searching os environ for PXR_AR_DEFAULT_SEARCH_PATH
2023-12-20 15:53:19:  0: PYTHON: C:/PROGRA~1/SIDEEF~1/HOUDIN~1.547;E:/Projects/RockinVFX/25_FHTG2

We are on deadline 10.2.0.10
Hoping there is something simple missing or perhaps a different callback is needed?

Cheers,
Luis

Myeah I think there is no mechanism to set env vars in event plugins.
SetProcessEnvironmentVariable sets variables for the subprocess of a normal plugin (a normal plugin runs some external program to do the work by default).
Oh actually you want to set variables that will be used by the render job. Try SetJobEnvironmentKeyValue. This will set key pairs in the job, that should be loaded when the render job starts.
https://docs.thinkboxsoftware.com/products/deadline/10.1/2_Scripting%20Reference/class_deadline_1_1_jobs_1_1_job.html#aefa406e5885fe093bb0736b6f91bc563