1

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 Answers 2

0

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))
Sign up to request clarification or add additional context in comments.

1 Comment

Can I use a @time remotecall_fetch to estimate the actual duration of "test" run?
0

Syntax issue, worker# should be at the end

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.