我只是想知道是否有一些python代码或我可以执行的魔法将重新启动ipython集群。似乎每次我更改我的代码时,都需要重新启动它。我可以从笔记本重新启动iPython群集吗?
3
A
回答
0
一个简单的想法,似乎是太生产的“哈克”:
设置的Client
并定义用于测试的简单功能。
import ipyparallel as ipp
c = ipp.Client()
dv = c[:]
# simple function
@dv.remote(block=True)
def getpid():
import os
return os.getpid()
getpid()
[1994, 1995, 1998, 2001]
定义重新启动集群的功能。 shutdown
与targets='all'
和hub=True
应该杀死整个群集。然后用!
或%sx魔法命令启动一个新簇。
import time
def restart_ipcluster(client):
client.shutdown(targets='all', hub=True)
time.sleep(5) # give the cluster a few seconds to shutdown
# include other args as necessary
!ipcluster start -n4 --daemonize
time.sleep(60) # give cluster ~min to start
return ipp.Client() # with keyword args as necessary
一个缺点这种方法是,DirectView的需要被重新分配,并重新执行装饰有dv.remote
dv.parallel
或需要的任何功能。
c = restart_ipcluster(c)
dv = c[:]
@dv.remote(block=True)
def getpid():
import os
return os.getpid()
getpid()
[3620, 3621, 3624, 3627]
读取源为ipyparallel Client
,上述shutdown
方法具有关键字参数,restart=False
,但它目前未实现。也许开发者正在开发一种可靠的方法。
+0
感谢您的建议;我会放弃它。主设计笔记本电脑没有过程控制的原因是否有原因? – cjm2671
相关问题
- 1. 启动IPython笔记本MPI群集
- 2. 延迟从笔记本启动IPython集群
- 3. ipython笔记本未启动
- 4. 启动iPython笔记本时出错
- 5. iPython笔记本自动创建新的空白笔记本
- 6. IPython笔记本在安装IPython dev版本后不会启动
- 7. 分配从IPython笔记本
- 8. 我可以在群集部署模式下运行pyspark jupyter笔记本吗?
- 9. 在Python程序中启动IPython,使用IPython笔记本连接
- 10. 无法创建新的ipython笔记本或启动jupyter
- 11. PyCharm可以在ipython笔记本上设置断点吗?
- 12. 在IPython笔记本上集中输出
- 13. 我可以从集装箱码头内重新启动码头集装箱吗?
- 14. 如何在ipython笔记本中创建新笔记本?
- 15. 如何启动IPython MPI群集?
- 16. (How)我可以在jupyter(ipython)中并排运行python 2.7和3.4笔记本吗?
- 17. 我可以从Jupyter笔记本中使用Dataflow for Python SDK吗?
- 18. 互动公众iPython笔记本
- 19. ipython笔记本中的动画图形
- 20. iPython笔记本没有嵌入动画
- 21. 运行IPython笔记本
- 22. IPython笔记本游戏
- 23. Heroku上的IPython笔记本
- 24. 测试IPython笔记本
- 25. IPython笔记本安全
- 26. ipython笔记本中的ASCIIMathMl
- 27. 在IPython的笔记本
- 28. 在IPython中/ Jupyter笔记本
- 29. ipython笔记本中的OptionParser?
- 30. Ipython笔记本丢失
我不知道是否有一个笔记本扩展可以做到这一点,但我会怀疑在笔记本内部运行的代码重新启动它,可能会导致无限循环的运行重新启动。 –