Opened 15 years ago
Closed 15 years ago
#933 closed bug (WontFix)
Issue with glib, threads and SIGCHLD eating 100% cpu
Reported by: | Plisk | Owned by: | andar |
---|---|---|---|
Priority: | minor | Milestone: | |
Component: | Unknown | Version: | |
Keywords: | cpu | Cc: |
Description
As it turned out if gtk2reactor is used instead of gtk.main() then after subprocess.Popen-ed process finishes deluge starts to eat 100% cpu. A simple examle:
import os import pygtk pygtk.require('2.0') import gtk from twisted.internet import gtk2reactor from twisted.internet.protocol import ProcessProtocol reactor = gtk2reactor.install() def on_button_clicked(button): #import subprocess #subprocess.Popen(['mplayer', '/mnt/d/11.avi']) reactor.spawnProcess(ProcessProtocol(), 'mplayer', ['mplayer', '/mnt/d/11.avi'], os.environ) sw = gtk.ScrolledWindow() win = gtk.Window() win.connect('delete-event', gtk.main_quit) button = gtk.Button(u"Press me!") button.connect("clicked", on_button_clicked) vbox = gtk.VBox() vbox.pack_start(button, gtk.FALSE) win.add(vbox) win.show_all() reactor.run() #gtk.main()
I tried to change subprocess.Popen to reactor.spawnProcess as twisted docs suggest but nothing changed. If in above example we change reactor.run() to gtk.main() and use subprocess.Popen - then no cpu eating occurs, but leaving zombie though, which we can address later i think, as it is not so important as issue with reactor.
Can gtkui be changed back to use gtk.main() ?
Change History (7)
comment:1 by , 15 years ago
comment:2 by , 15 years ago
Milestone: | → 1.2.0 |
---|---|
Version: | 1.1.7 → 1.2.0_dev |
comment:3 by , 15 years ago
I just tried the above code and I had it start vlc, I then closed vlc and checked for the cpu usage and it was normal.. So I cannot reproduce this..
comment:4 by , 15 years ago
So i debugged it a bit more and it resulted in this:
import signal, subprocess import gtk, gobject gobject.threads_init() def on_button_clicked(button): subprocess.Popen(['xine', '/mnt/d/Movies/AI.avi']) win = gtk.Window() win.connect('delete-event', gtk.main_quit) button = gtk.Button(u"Press me!") button.connect("clicked", on_button_clicked) vbox = gtk.VBox() vbox.pack_start(button, gtk.FALSE) win.add(vbox) win.show_all() def sig_handler(num, frame): print 11 signal.signal(signal.SIGCHLD, sig_handler) gtk.main()
Twisted calls behind the scenes gobject.threads_init() and sets SIGCHLD handler. Somehow because of this happens that cpu usage 100%... If i remove gobject.threads_init() or that SIGCHLD handler - its OK then. So its something has to do with threads i guess...
comment:5 by , 15 years ago
Summary: | Issue with twisted's gtk2reactor eating 100% cpu → Issue with glib, threads and SIGCHLD eating 100% cpu |
---|
Made the test case more simple. Now i'm stuck.
import signal, subprocess import gobject, glib def sig_handler(num, frame): print 11 gobject.threads_init() signal.signal(signal.SIGCHLD, sig_handler) subprocess.Popen('xine') glib.MainLoop().run()
comment:6 by , 15 years ago
Milestone: | 1.2.0 |
---|---|
Version: | 1.2.0_dev |
comment:7 by , 15 years ago
Resolution: | → wontfix |
---|---|
Status: | new → closed |
This is a bug in pygtk: https://bugzilla.gnome.org/show_bug.cgi?id=481569
Relevant twisted bug: http://twistedmatrix.com/trac/ticket/3096
This is not a bug with Deluge, so closing.
As far as I can tell, gtk.main() is called from the reactor.run() and if you don't call reactor.run() then the twisted loop will not run..