File tree Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Expand file tree Collapse file tree 1 file changed +7
-7
lines changed Original file line number Diff line number Diff line change @@ -40,17 +40,17 @@ def reduce_hook(obj):
40
40
captured_connections .append (obj )
41
41
return stub_unpickler , ()
42
42
43
- # TODO(VitalyFedyunin): Better do it as `with` context for safety
44
- IterDataPipe .set_reduce_ex_hook (reduce_hook )
45
- if exclude_primitive :
46
- IterDataPipe .set_getstate_hook (getstate_hook )
47
43
try :
44
+ IterDataPipe .set_reduce_ex_hook (reduce_hook )
45
+ if exclude_primitive :
46
+ IterDataPipe .set_getstate_hook (getstate_hook )
48
47
p .dump (scan_obj )
49
48
except AttributeError : # unpickable DataPipesGraph
50
49
pass # TODO(VitalyFedyunin): We need to tight this requirement after migrating from old DataLoader
51
- IterDataPipe .set_reduce_ex_hook (None )
52
- if exclude_primitive :
53
- IterDataPipe .set_getstate_hook (None )
50
+ finally :
51
+ IterDataPipe .set_reduce_ex_hook (None )
52
+ if exclude_primitive :
53
+ IterDataPipe .set_getstate_hook (None )
54
54
return captured_connections
55
55
56
56
You can’t perform that action at this time.
0 commit comments