Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
4 views
in Python by (200 points)

Hello guys, I love programming and I'm totally new to python. Moreover, I'm getting some unusual error Segmentation fault (core dumped)

when I tried to execute the code:

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, bufsize= 4024)
        q = Queue()
        t = threading.Thread(target=enqueue_output, args=(p.stdout, q))
        #t = Thread(target=enqueue_output, args=(p.stdout, q))
        t.daemon = True # thread dies with the program
        t.start()
# ... do other things here
        def myfunc(q):
            while True:
                try: line = q.get_nowait()
         # or q.get(timeout=.1)
                except Empty:
                    print('Vacio')
                else: # got line
    # ... do something with line
                    print line  
        thread = threading.Thread(target=myfunc, args=(q,))
        thread.start()
In this following code, when I try to execute "myfunc" function, it works fine in out of thread, But when I try to run the same function inside the thread it fails, I request anyone to clear my doubt !!

1 Answer

0 votes
by (26.4k points)

If you're getting an error like this Segmentation fault (core dumped), this actually means that the python interpreter has been crashed. This can happen only when :

1. There might be something wrong with your installation of python

2. You're using a third party extension module which is written in C language, and that extension module might be crashed.

3. You're using ctypes (built-in module), and it crashes when you call external code

4. There is a bug which you've discovered in python, that you should report.

You can also become an expert in Python. Come & join our python course

To know more about these topics, you can also look at the following video tutorial:

Related questions

0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...