lordmauve / chopsticks

Chopsticks is an orchestration library: it lets you execute Python code on remote hosts over SSH.
https://chopsticks.readthedocs.io/
Apache License 2.0
158 stars 16 forks source link

Decorated functions can't be called remotely #50

Open amigrave opened 7 years ago

amigrave commented 7 years ago

The following code actually doesn't work...

from chopsticks.tunnel import SSHTunnel

def deco(fn):
    return fn

@deco
def do_it():
    return 'done'

tunnel = SSHTunnel('root@192.168.56.103')
print(tunnel.call(do_it))

... because when building the source code to send, serialise_func() will append sub dependency functions below the original callable, hence when the code is remotely unpickled and executed, the decorator function is not yet declared.