Reply
Thread Tools
Posts: 187 | Thanked: 41 times | Joined on May 2010
#1
Hi , i am trying to learn dbus to make a few changes to the call proccess but i am facing a problem that i can not understand.

Here is a very simple example of a python code that SHOULD reject a call with their respective output.
Code:
import gobject
import dbus
import time
import datetime
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

bus = dbus.SystemBus()
sbus = dbus.SessionBus()

def disconnect():
        print 'Running disconnect() at' + str(datetime.datetime.now())
        callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1')
        smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance')
        print smsiface.Release()

def callDetected(state):
        print 'callDetected() at' +  str(datetime.datetime.now())
        disconnect()

sbus.add_signal_receiver(callDetected,dbus_interface="org.freedesktop.Telepathy.Connection.Interface.Requests",signal_name="NewChannels")
gobject.MainLoop().run()
When the signal NewChannels is received the callDetected function is executed and then execute the disconnect() method.
Since, i believe, the call is not fully established release will execute but not drop the call. Here is the output...

callDetected() at2010-12-02 22:30:23.555880
Running disconnect() at2010-12-02 22:30:23.557619

The disconnect was executed almost at the same time frame that callDetected() like i expect.


Now, i added a delay before execute the disconnect() method to give time to the connection be really made so i would expect the connection be dropped just fine.


Code:
import gobject
import dbus
import time
import datetime
from dbus.mainloop.glib import DBusGMainLoop
dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)

bus = dbus.SystemBus()
sbus = dbus.SessionBus()

def disconnect():
        print 'Running disconnect() at' + str(datetime.datetime.now())
        callobject = bus.get_object('com.nokia.csd.Call', '/com/nokia/csd/call/1')
        smsiface = dbus.Interface(callobject, 'com.nokia.csd.Call.Instance')
        print smsiface.Release()

def callDetected(state):
        print 'callDetected() at' +  str(datetime.datetime.now())
        time.sleep(1)
        disconnect()

sbus.add_signal_receiver(callDetected,dbus_interface="org.freedesktop.Telepathy.Connection.Interface.Requests",signal_name="NewChannels")
gobject.MainLoop().run()
The problem is that the disconnect is being run almost ten seconds after the first output line.

callDetected() at2010-12-02 22:33:13.602907
Running disconnect() at2010-12-02 22:33:22.481692


Why if i put it to sleep 1 second, the delay is over 11 seconds ?

One thing i have noticed is that during these 11 seconds i can not even type in the ssh shell, it is like the phone is too busy ... though the UI is answering just fine.
 
Posts: 1,463 | Thanked: 1,916 times | Joined on Feb 2008 @ Edmonton, AB
#2
i would try to disable the cpu scheduler with the instructions here:
http://talk.maemo.org/showthread.php?t=47479
sleep commands usually put threads to sleep for a minimum amount of time, and it's usually going to sleep for longer than you specify. if the cpu scheduler decides the incoming call is important, it might ignore your thread for a while. i dunno. maybe you have some other error but i don't know python
 
Posts: 235 | Thanked: 339 times | Joined on Nov 2010
#3
Originally Posted by colchaodemola View Post
One thing i have noticed is that during these 11 seconds i can not even type in the ssh shell, it is like the phone is too busy ... though the UI is answering just fine.
http://www.pygtk.org/pygtk2reference...t--timeout-add

If gobject.timeout_add_seconds is available, you may prefer to use that instead.
 
Posts: 187 | Thanked: 41 times | Joined on May 2010
#4
disable cgroups make the application works fine ...
Is there any colateral effect doing this ?
 
Posts: 3 | Thanked: 2 times | Joined on Dec 2010
#5
You will notice phone app may lag on heavy load and you will miss calls.
 
Reply


 
Forum Jump


All times are GMT. The time now is 23:03.