使用Python进行并行计算
这是我的 python 脚本的代码:
import time
for j in range(1,150,1):
for i in range(1,5,1):
x = j + i
print(x)
time.sleep(180)
该脚本是从我的有限元程序启动的,可以由 python 操作。如果我启动这个脚本,它就会开始运行,但是如果调用 time.sleep 被激活,有限元程序也会停止工作。脚本的主要任务是开始打印 5 次“x”,停止脚本一段时间,然后再次打印 5 次“x”。最终程序中使用了另一个命令,而不是“打印”。必须避免 FE 程序停止。我该如何处理?我已经尝试过不同的事情,例如线程,但这也不起作用。您的意思是可以通过使用并行进程来解决问题吗? 感谢您的建议。
here is the code of my python script:
import time
for j in range(1,150,1):
for i in range(1,5,1):
x = j + i
print(x)
time.sleep(180)
This script is started out of my Finite Element programm which can be manipulated by python. If i start this script it starts to run, but if the call time.sleep is activated the Finite Element program also stops working. The main task of the script shall be to start print 5 times "x" stop the script for a certain time and print 5 times "x" again. Instead of "print" another command is used in the final program. The stopping of the FE program has to avoided. How can i manage that? I already tried different things, e.g. threading, but that doesn't work too. Do you mean the problem can be solved by using parallel processes?
Thanks for your suggestions.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你打算做这样的事情吗:
Do you intend to do something like this: