[Sugar-devel] Communication between two Activities
gus.duarte at gmail.com
Thu May 21 23:49:03 EDT 2015
thank you very much, for your clear explanation.
El 20/05/2015 20:07, "James Cameron" <quozl at laptop.org> escribió:
> On Wed, May 20, 2015 at 10:43:23AM -0300, Gustavo Duarte wrote:
> > Notificator: There is a Sugar Activity who shows Notification messages
> > for the kid.
> > Daemon: There is an script running on cron, who get new notification
> > from a Server.
> > I need communicate the Daemon with the Notificator, so when Daemon
> > receive a new notification from Server, it'll send a signal to
> > Notificator.
> > Notificator when receive the signal, should refresh a widget.
> > I know a way to do that, using system signals, but i wonder if Sugar
> > has another way to achieve that.
> What you describe is interprocess communication.
> Sugar uses several methods for communication with system daemons.
> The most frequently coded is D-Bus.
> Other methods in Python are
> You can use files, as Gonzalo says, but try to place them in a path
> that does not cause writes to disk; e.g. /tmp ... otherwise sometimes
> the kernel will reschedule the process that is writing, and this can
> slow performance.
> My preference for your scenario is signals:
> 1. Notificator calls os.getpid and writes to /tmp/notificator.pid
> 2. Notificator calls signal.signal to request a callback on SIGUSR1,
> 3. Daemon reads /tmp/notificator.pid and calls os.kill(pid, SIGUSR1),
> kill(1), or kill(3) to send signal.
> An example here:
> Signals become more complex if the communication is complex, and there
> are a limited number of different signals. That's when I would
> suggest D-Bus.
> James Cameron
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Sugar-devel