python activities startup
Tomeu Vizoso
tomeu at tomeuvizoso.net
Wed Feb 6 15:11:30 EST 2008
On Wed, 2008-02-06 at 09:59 -0500, Benjamin M. Schwartz wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Tomeu Vizoso wrote:
> > If I understand correctly how that fork() would work, what we would be
> > saving in that case is the reading of modules, but the python code at
> > the module scope would need to be executed anyway.
>
> I am no expert, but, without evidence, my current suspicion is the other way.
> Consider:
>
> import dbus
> import os
>
> def launch_activity(some_activity)
> if os.fork() == 0:
> import some_activity
> x = some_activity.SomeActivity()
> else:
> return
>
> - From the perspective of the child process, the modules have already been
> imported, and are even still in scope. It would be strange for the Python
> semantics if the imports were somehow "forgotten" in the child.
You are right.
I have hacked the rainbow service in the following way:
- rainbow preimports pygtk, telepathy, dbus and some slow sugar modules.
- after cloning, reconnect to X.
- instead of execvpe sugar-activity, directly execute the code.
Python activities have the expected speedup, from 7 seconds to 3.
Haven't measured the memory usage improvement yet.
The visible problems right now are that the D-Bus connection to the
session bus is stale (how can we reconnect?) and that the activity uses
the default gtk theme and not the Sugar one. These two should be quite
easily solvable.
I think Michael, Scott and Chris played in the past with this idea. What
was your conclusion? Anybody saw any flaw with this approach? Security
implications?
Thanks,
Tomeu
More information about the Devel
mailing list