python程序在命令行中停止 [英] python program stops in command line

查看:881
本文介绍了python程序在命令行中停止的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我用python搜索了很多有关问题VMware的信息,但没有找到有关我的问题的任何信息。
我的问题是python程序冻结,进程仍在运行,但不使用CPU,内存使用情况也没有变化。
程序不会返回任何异常或任何东西,它只是冻结而不会返回执行。
看来它是随机发生的,这对我的机器没有可用内存不是问题,因为与此同时,我可以在另一个会话中执行它。

I searched a lot about problem VMware with python, but I didn't find any information about my problem. My problem is that python programs freeze, process is still running but it doesn't use CPU and memory usage doesn't change. Program doesn't return any exception or anything... it just freeze and it never back to execution. It looks that it happens randomly and it is not a problem with no memory available for my machine, because in the same time I can execute it in another session.

我的机器是虚拟机,具有:Windows Server 2008 64位,VMware Tools 9.4.5

My machine is virtual machine with: Windows Server 2008 64-bit, VMware Tools 9.4.5

我尝试使用python:2.7、3.3和3.4

I tried python: 2.7, 3.3 and 3.4

我的示例脚本:(但不仅冻结了此脚本)

my example script: (but not only this script freeze)

print("START")
for i in range(0, 1000): 
  print("step: " + str(i)) 
  file = open("./test_file.csv", "r") #file size is 1.2GB but I have 10GB RAM
  for line in file.readlines(): 
    pass    
  file.close() #close the file
print("END")

示例输出为:

START
step 0
step 1
step 2
step 3
step 4

它冻结,它是随机地在哪一步上执行(有时是4、15、34 ...),我所能做的就是杀死处理并再次运行。
在执行过程中,我可以看到该程序可重复使用1,2GB RAM和发布...使用和发布。冻结总是在释放内存之后进行,从那时起,此过程的内存使用率是稳定的,CPU使用率是0%。

and it freeze, it is randomly on which step (sometimes 4, 15, 34...) All what I can do is kill the process and run it again. During the execution I can see that program repeatable use 1,2GB RAM and release... use and release. Freeze is always after release memory and from this time memory usage is stable and CPU usage 0% for this process.

我在IDLE中运行脚本以与调试器和堆栈一起玩查看器,但是当程序冻结时,整个空闲都没有响应。
我也曾在其他非虚拟机上尝试过,也没有问题。

I run the script in IDLE to play with debugger and stack viewer, but when the program freeze, the whole idle is not responding. Also I tried it on others no-virtual machine and there is no problem.

对于任何建议,如何解决或调试此类建议,我将不胜感激。问题。

I would be grateful for any suggestions, how to solve or debug that kind o problems.

推荐答案

我解决了这个问题,问题不在于python或VMware ....仅凭我对Microsoft的了解产品。

I solved it, the problem was not with python or VMware.... only with my knowledge about Microsoft products.

我没有提到我使用Windows命令行执行python脚本,并且冻结的原因是cmd。
我不知道如果在命令行中标记了sth,将暂停执行的任务。

I did not mentioned that I execute python scripts using windows command line, and the reason of the "freeze" was cmd. I had no idea that cmd suspends executed task if you mark sth in command line.

仅在该虚拟机上设置快速编辑模式。您可以按照以下步骤进行更改:右键单击cmd面板->属性->选项卡:选项->部分:快速编辑模式)

Only on this virtual machine I had set up "QuickEdit Mode". You can change it following steps: right click on panel of cmd -> properties -> tab: "Options" -> section: "QuickEdit Mode")

在此模式下如果单击命令行,它将标记sth并...暂停执行的任务...
我关闭了 QuickEdit Mode,程序运行正常。
如果没有快速编辑模式,则不能通过单击在命令行中标记任何内容。

In this mode if you click on command line it will mark sth and... suspend executed task… I turned off the "QuickEdit Mode" and program works perfectly. Without QuickEdit Mode you can not mark anything in command line by clicking.

我知道...我应该感到羞耻...我这样做。

I know... I should shame myself... and I do.

这篇关于python程序在命令行中停止的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆