Set up the worker by calling the user-defined setup function.
(self, worker)
| 201 | self.setup_fn = setup_fn |
| 202 | |
| 203 | def setup(self, worker): |
| 204 | """Set up the worker by calling the user-defined setup function.""" |
| 205 | env = self.setup_fn() |
| 206 | if not isinstance(env, dict): |
| 207 | raise ValueError("setup_fn must return a dict") |
| 208 | worker.plugins["env"] = env |
| 209 | |
| 210 | # Set worker id so that users can use it for identifing workers |
| 211 | os.environ["DASK_WORKER_ID"] = str(worker.id) |
| 212 | |
| 213 | |
| 214 | def wrap_func_with_worker_env(func: Callable) -> Callable: |