Ticket #117 (defect)
Opened 2 years ago
Last modified 2 years ago
Null tstate with notify-python and threading
Status: new
| Reported by: | dgoodwin@dangerouslyinc.com | Assigned to: | chipx86 |
|---|---|---|---|
| Priority: | normal | Milestone: | |
| Component: | notify-python | Version: | |
| Severity: | normal | Keywords: | pynotify add_action assertion tstate failed |
| Cc: | gallegosja@gmail.com | D-BUS Version: | |
| Patch Included: | 0 | OS/Distro Version: | Fedora Core 6 x86_64 |
I'm not certain if I'm onto a bug here or just bad code on our end, but we have a program that uses notify-python for displaying user notifications, and started crashing after the user clicks a button in the notification bubble after we introduced threading.
To debug the problem I started putting together the smallest piece of code possible that I could replicate the error with.
#!/usr/bin/env python
import pynotify
from egg import trayicon
import gtk
gtk.gdk.threads_init()
def accept(self, notification, action):
print "accepted"
if __name__ == "__main__":
tray_icon = trayicon.TrayIcon("testicon")
tray_image = gtk.Image()
tray_image.set_from_stock(gtk.STOCK_DIALOG_INFO,
gtk.ICON_SIZE_SMALL_TOOLBAR)
event_box = gtk.EventBox()
event_box.add(tray_image)
tray_icon.add(event_box)
tray_icon.show_all()
pynotify.init("Title")
notify = pynotify.Notification("Title", "Hello world!")
notify.attach_to_widget(tray_icon)
notify.set_timeout(0)
notify.add_action('accept', 'Accept', accept)
notify.show()
gtk.main()
This fails as soon as the user presses the "Accept" button (i.e. before reaching the callback) with the following exception on Fedora Core 6 x86_64:
python: Python/ceval.c:2531: PyEval_EvalCodeEx: Assertion `tstate != ((void *)0)' failed.
I tested this on Ubuntu Egdy i386 running within Vmware and saw a similar result, although this time just a segfault and not as informative a message, I suspect the problem is the same.
Note that commenting out the threads_init() call will allow the program to function properly, as soon as that line alone is added the error begins to happen.
I also tried a version of the code where the notification was displayed from within a seperate thread, but the result was the same. For this I used a modified version of this program similar to that of this article: http://aruiz.typepad.com/siliconisland/2006/04/threads_on_pygt.html
After this I began to wonder if there might be a bug with notify-python and threading, although I'm aware most programmers like to think the bug is anywhere but their own code. :) Anyhow I thought I should submit the potential problem just the same.
Cheers.
Change History
04/27/07 14:22:49: Modified by kad
- cc set to gallegosja@gmail.com.
- keywords set to pynotify add_action assertion tstate failed.

Well, yeah I'm having the same problem. Same error actually, this from a fedora 6 box, another thing, can we put a callback within a class? so far I've only seen calls to defs outside of classes... for example, the following code doesn't work (being part of a class, obviously):
def echo(self, n, action): print "hello" def alert(self, title, message): n = pynotify.Notification(title, message, gtk.STOCK_DIALOG_WARNING) n.set_timeout(0) n.add_action("extend", "Extend task", self.echo) n.show()But making the Notification object a part of the class borks with the same error reported above.
def alert(self, title, message): self.n = pynotify.Notification(title, message, gtk.STOCK_DIALOG_WARNING) self.n.set_timeout(0) self.n.add_action("extend", "Extend task", self.echo) self.n.show()So I guess the correct way to do it is the second, but it raises an error.