Skip to content

Commit 97cedb1

Browse files
committed
streaming: Don't accidentally serialize TLS
1 parent 5c5c475 commit 97cedb1

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/stream.jl

+6-3
Original file line numberDiff line numberDiff line change
@@ -300,7 +300,7 @@ function migrate_stream!(stream::Stream, w::Integer=myid())
300300

301301
# TODO: Wire up listener to ferry cancel_token notifications to remote
302302
# worker once migrations occur during runtime
303-
tls = get_tls()
303+
tls = poolset(get_tls())
304304
@assert w == myid() "Only pull-based migration is currently supported"
305305
#remote_cancel_token = clone_cancel_token_remote(get_tls().cancel_token, worker_id)
306306

@@ -322,8 +322,11 @@ function migrate_stream!(stream::Stream, w::Integer=myid())
322322
# Initialize the StreamStore on the destination with the unsent inputs/outputs.
323323
STREAM_THUNK_ID[] = thunk_id
324324
@assert !in_task()
325-
set_tls!(tls)
326-
#get_tls().cancel_token = MemPool.access_ref(identity, remote_cancel_token; local_only=true)
325+
326+
# N.B. It's not very valid to share TLS across tasks, but we do this
327+
# so that input/output tasks have access to TID and cancel token
328+
set_tls!(copy(MemPool.access_ref(identity, tls; local_only=true)))
329+
327330
unsent_inputs, unsent_outputs = unsent
328331
for (input_uid, inputs) in unsent_inputs
329332
input_stream = store.input_streams[input_uid]

0 commit comments

Comments
 (0)