Comments (9)
Hi, great project. Is there any workaround for this issue?
from chopsticks.
There are several. The cleanest one is is to make sure that the functions you want to call remotely are in a separate module to your __main__
module. This is good organisational practice anyway.
from chopsticks.
Sorry, I should have thought of that before I posted! Thanks very much.
from chopsticks.
If you want a single-file solution, there is one, but it's subtle and cludgey:
Say your script is called my_script.py
:
def my_remote_func():
...
if __name__ == '__main__':
from my_script import my_remote_func
# now my_remote_func is my_script.my_remote_func, which can be unpickled
from chopsticks.tunnel import Tunnel
Tunnel(hostname).call(my_remote_func)
from chopsticks.
Very kind of you to provide that snippet - I will use it. Just trying out Chopsticks quickly for first time today and was too lazy to use modules! It's already saved me some time.
from chopsticks.
The same (or a very similar) issue exists in Python 3, with a much less friendly error:
chopsticks.tunnel.RemoteException: Host 'local' raised exception; traceback follows
Traceback (most recent call last):
File "bubble.py", line 139, in wrapper
File "bubble.py", line 152, in handle_call_thread
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "bubble.py", line 119, in load_module
File "controller://run.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 969, in _find_and_load
File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 664, in _load_unlocked
File "<frozen importlib._bootstrap>", line 634, in _load_backward_compatible
File "bubble.py", line 119, in load_module
File "controller://chopsticks/tunnel.py", line 358, in <module>
class SubprocessTunnel(PipeTunnel):
File "controller://chopsticks/tunnel.py", line 366, in SubprocessTunnel
'__bubble = sys.stdin.read(%d); ' % len(bubble) +
TypeError: object of type 'NoneType' has no len()
from chopsticks.
@romanlevin - that's actually caused by issue #6.
Specifically, issue #6 means you can't import chopsticks on the remote host at the moment. If you move your chopsticks imports to the if __name__ == __main__
block, then it should work.
from chopsticks.
@lordmauve oh I see, thanks!
from chopsticks.
The solution to issue #17 will fix this issue also.
from chopsticks.
Related Issues (20)
- Error importing packages that use pbr HOT 1
- Call logging.basicConfig on tunnel start HOT 1
- EP2017 Sprint details HOT 2
- Failing to instantiate an object causes traceback HOT 1
- Jupyter notebook import doesn't work recursively HOT 1
- Error when dis._unpack_opargs() does not exist
- Issues reported by lgtm.com
- Create a benchmark suite
- Write documentation for passwordless SSH
- Error when trying to print env HOT 2
- Decorated functions can't be called remotely
- Traceback on slow connections when using python3 HOT 4
- Howto create Tunnel with ssh password HOT 5
- ErrorResult does not compare equal
- ImportError from deserialise_func
- Tunnel destructor prevents subsequent stderr interception HOT 1
- Comparison with multiprocessing remote manager
- can not call simple commands HOT 1
- RFC: pencode performance improvements
- Prompt responder
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chopsticks.