# Easy way to send custom function to distributed workers?

**URL:** <https://discourse.julialang.org/t/easy-way-to-send-custom-function-to-distributed-workers/22118>\
**Category:** Julia at Scale\
**Created:** [March 20, 2019, 6:41pm UTC](https://discourse.julialang.org/t/easy-way-to-send-custom-function-to-distributed-workers/22118 "2019-03-20T18:41:19Z")\
**Posts on this page:** 1\
**Showing post:** 2

<div class="post-metadata">

**Author:** ![greg\_plowman](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/greg_plowman/32/8100_2.png) [@greg\_plowman](https://discourse.julialang.org/u/greg_plowman)\
**Post date:** [March 21, 2019, 12:53am UTC](https://discourse.julialang.org/t/easy-way-to-send-custom-function-to-distributed-workers/22118/2 "2019-03-21T00:53:08Z")

</div>

I think the issue here is that you want define _methods_ (not just the function) on the workers.

I’m not sure how robust this is but it seems to work for your simple example:

```julia
function my_func(x)
    #println("Calculating my_func($x)")
    return x ^ 2
end

using Distributed
addprocs(4)

@everywhere workers() @eval function my_func end

for m in methods(my_func)
    @everywhere workers() @eval $m
end

pmap(my_func, 1:100)

```

---

_[View the full topic](https://discourse.julialang.org/t/easy-way-to-send-custom-function-to-distributed-workers/22118)._
