Variant of distributed.utils_comm.subs_multiple, which allows injecting bind_to
(o)
| 236 | is_leaf: bool |
| 237 | |
| 238 | def clone_value(o): |
| 239 | """Variant of distributed.utils_comm.subs_multiple, which allows injecting |
| 240 | bind_to |
| 241 | """ |
| 242 | nonlocal is_leaf |
| 243 | |
| 244 | typ = type(o) |
| 245 | if typ is tuple and o and callable(o[0]): |
| 246 | return (o[0],) + tuple(clone_value(i) for i in o[1:]) |
| 247 | elif typ is list: |
| 248 | return [clone_value(i) for i in o] |
| 249 | elif typ is dict: |
| 250 | return {k: clone_value(v) for k, v in o.items()} |
| 251 | else: |
| 252 | try: |
| 253 | if o not in keys: |
| 254 | return o |
| 255 | except TypeError: |
| 256 | return o |
| 257 | is_leaf = False |
| 258 | return clone_key(o, seed) |
| 259 | |
| 260 | dsk_new = {} |
| 261 | bound = False |