Hi All:
I'm chasing down a problem where the Python process for Orca goes
ballistic when someone kills brltty. The net result is that the desktop
hangs, which is bad news.
Orca does a gobject.io_add_watch on the brlAPI.fileDescriptor and then
calls brlAPI.readKey in the callback that is notified when there is
activity.
Using the trace facility of Python, I'm not sure I'm seeing any loops
happening and I'm also not getting any exceptions from BrlAPI calls from
what I can tell. I'm also not seeing any abnormal condition value being
sent to the io callback. I've tried doing an os.fstat on the BrlAPI
file descriptor before doing the BrlAPI readKey call, and it seems fine,
too.
Attached is a simple application that doesn't exhibit the same hang as
Orca, but it does seg fault. What I do is run brltty in a terminal
window, and then this app in another. I then kill brltty and observe
what happens to this app. Ideally, the application should be able to
detect that brltty has disappeared.
Any ideas on what I should be able to do in Python to detect that brltty
has been killed?
Will
import os
import brlapi
import gobject
import pyatspi
brlAPI = None
brlAPIRunning = False
brlAPISourceId = 0
def printBrailleEvent(command):
print("BRAILLE EVENT: %s" % repr(command))
def brlAPIKeyReader(source, condition):
"""Method to read a key from the BrlAPI bindings. This is a
gobject IO watch handler.
"""
global brlAPIRunning
print "HERE"
try:
print os.fstat(brlAPI.fileDescriptor)
except:
print "BAD FILE DESCRIPTOR!!!"
return False
try:
key = brlAPI.readKey(False)
if key:
printBrailleEvent(brlAPI.expandKeyCode(key))
except:
print "OOPS!"
brlAPIRunning = False
return brlAPIRunning
def init(tty=7):
global brlAPI
global brlAPIRunning
global brlAPISourceId
gobject.threads_init()
brlAPI = brlapi.Connection()
try:
brlAPI.enterTtyModeWithPath()
brlAPIRunning = True
except:
brlAPI.enterTtyMode(tty)
brlAPIRunning = True
if brlAPIRunning:
brlAPISourceId = gobject.io_add_watch(brlAPI.fileDescriptor,
gobject.IO_IN,
brlAPIKeyReader)
if __name__ == "__main__":
init()
pyatspi.Registry.start(gil=False)
_______________________________________________
This message was sent via the BRLTTY mailing list.
To post a message, send an e-mail to: [email protected]
For general information, go to: http://mielke.cc/mailman/listinfo/brltty