Skip to content

Commit 9d946ac

Browse files
Fix user interrupt
1 parent 3f10baf commit 9d946ac

File tree

2 files changed

+11
-8
lines changed

2 files changed

+11
-8
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: future.p2p
22
Title: A Peer-to-Peer Compute Cluster via Futureverse
3-
Version: 0.3.0-9016
3+
Version: 0.3.0-9017
44
Description: Implementation of the 'Future' API <doi:10.32614/RJ-2021-048> that resolves futures on a peer-to-peer ('P2P') compute environment. By using this future backend, you and your friends can share your spare compute resources with each other.
55
Imports:
66
future (>= 1.67.0),

R/worker.R

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,11 @@ worker <- function(cluster = p2p_cluster_name(), host = "pipe.pico.sh", ssh_args
160160
writeLines(err, con = stderr())
161161
}
162162

163+
if (state == "exit") {
164+
info("Terminating worker")
165+
break
166+
}
167+
163168
## Handle worker status updates
164169
if (length(worker_status) > 0) {
165170
worker_status <- sub("^worker_status=", "", worker_status)
@@ -173,11 +178,6 @@ worker <- function(cluster = p2p_cluster_name(), host = "pipe.pico.sh", ssh_args
173178
}
174179
}
175180

176-
if (state == "exit") {
177-
info("Terminating worker")
178-
break
179-
}
180-
181181
## Expired?
182182
if (Sys.time() > expires) {
183183
info("time is out")
@@ -333,12 +333,15 @@ worker <- function(cluster = p2p_cluster_name(), host = "pipe.pico.sh", ssh_args
333333
## FIXME: Acknowledge withdrawal of future
334334
}, interrupt = function(c) {
335335
info("interrupted")
336-
## Interrupt worker
337-
rx$interrupt()
338336
state <<- "exit"
339337
offer_expires <<- Inf
340338
future <<- NULL
341339
client <<- NULL
340+
341+
## Interrupt worker
342+
info("interrupting worker")
343+
rx$interrupt()
344+
342345
## FIXME: Update the P2P message board
343346
info("exiting")
344347
}) ## repeat tryCatch({ ... })

0 commit comments

Comments
 (0)