我是python的新手,我得到一个奇怪的错误:
Segmentation fault (core dumped)
Run Code Online (Sandbox Code Playgroud)
当我执行以下代码时:
class Workspace(QMainWindow, Ui_MainWindow):
""" This class is for managing the whole GUI `Workspace'.
Currently a Workspace is similar to a MainWindow
"""
def __init__(self):
#p= subprocess.Popen(["java -Xmx256m -jar bin/HelloWorld.jar"],cwd=r'/home/karen/sphinx4-1.0beta5-src/sphinx4-1.0beta5/', shell=True, stdout=subprocess.PIPE, bufsize= 4024)
try:
from Queue import Queue, Empty
except ImportError:
while True:
#from queue import Queue, Empty # python 3.x
print "error"
ON_POSIX = 'posix' in sys.builtin_module_names
def enqueue_output(out, queue):
for line in iter(out.readline, b''):
queue.put(line)
out.close()
p= Popen(["java -Xmx256m -jar bin/HelloWorld.jar"],cwd=r'/home/karen/sphinx4-1.0beta5-src/sphinx4-1.0beta5/',stdout=PIPE, shell=True, …Run Code Online (Sandbox Code Playgroud) 我们遇到了这个错误:
http://bugs.python.org/issue1856守护程序在解释器关闭期间断言段错误.
现在我搜索一种代码来解决这个bug.
目前代码如下所示:
while True:
do_something()
time.sleep(interval)
Run Code Online (Sandbox Code Playgroud)
有没有办法在do_something()之前检查解释器是否仍然可用?
或者最好不要执行mythread.setDaemon(True)并检查主线程是否已退出?