1
votes

I'm trying to kill execution of a function when it times out. Tried to leverage the post here: Julia: Can you set a time limit on eval

It errored on RemoteRef is undefined (I'm using v0.6.0). Replaced RemoteRef with Channel(1). Now the error is

MethodError: no method matching remotecall_fetch (::Int64, ::#test, ::String, ::String, ::String)

addprocs(1) 
@everywhere include("test.jl")  
response = Channel(1)
@async put!(response, remotecall_fetch(2, test, arg1, arg2, arg3))

start=time()
while !isready(response) && (time() - start) < timeoutDuration    
  sleep(0.1)
end

elapsedtime = time()-start

ERROR (unhandled task failure): MethodError: no method matching remotecall_fetch(::Int64, ::#test, ::String, ::String, ::String)

Also tried

@async put!(response, remotecall_fetch(2, ()->test(arg1, arg2, arg3)))

ERROR (unhandled task failure): MethodError: no method matching remotecall_fetch(::Int64, ::##10#12)

Is the second worker unable to find test()?

2

2 Answers

0
votes

According to the documentation:

help?> remotecall_fetch
search: remotecall_fetch remotecall_wait

  remotecall_fetch(f, id::Integer, args...; kwargs...)

  Perform fetch(remotecall(...)) in one message. Keyword arguments,
  if any, are passed through to f. Any remote exceptions are captured 
  in a RemoteException and thrown.

  See also fetch and remotecall.

  remotecall_fetch(f, pool::AbstractWorkerPool, args...; kwargs...) -> result

  WorkerPool variant of remotecall_fetch(f, pid, ....). Waits for and 
  takes a free worker from pool and performs a remotecall_fetch on it.

You'd need to do it like this:

@async put!(response, remotecall_fetch(test, 2, arg1, arg2, arg3))
0
votes

Syntax issue, worker# should be at the end

@async put!(response, remotecall_fetch(()->test(a1,a2,a3),2) )