Waits and fetches a value from x depending on the type of x. Does not remove the item fetched:

  • RemoteRef: Wait for and get the value of a remote reference. If the remote value is an exception, throws a RemoteException which captures the remote exception and backtrace.
  • Channel : Wait for and get the first available item from the channel.


  1. Fetch a value from a RemoteRef:

    julia> ref = RemoteRef(42);
    julia> fetch(ref)

    This example waits for and retrieves the value of a RemoteRef object.

  2. Fetch the first available item from a Channel:
    julia> channel = Channel(1);
    julia> put!(channel, "Hello");
    julia> fetch(channel)

    Here, the fetch function is used to wait for and retrieve the first available item from a Channel.

Common mistake example:

julia> arr = [1, 2, 3];
julia> fetch(arr)
ERROR: MethodError: no method matching fetch(::Array{Int64,1})

In this example, the fetch function is incorrectly used on an array. It's important to note that fetch is not applicable to all types, and it should be used specifically for RemoteRef and Channel objects.

See Also

accept, bind, :@spawn, connect, fetch, getaddrinfo, gethostname, getipaddr, getsockname, init_worker, IPv4, IPv6, isready, issocket, kill, listen, recv, recvfrom, remotecall, remotecall_fetch, remotecall_wait, RemoteRef, send, setopt,

User Contributed Notes

Add a Note

The format of note supported is markdown, use triple backtick to start and end a code block.

*Required Field

Checking you are not a robot: