I'm writing an application that has an appindicator in python. It works mostly fine, but now I want to fork the execution so the application starts up "in the tray" and releases the console. The problem is that it takes about 10 to 15s for the indicator to show app after the application is forked. Here's some minimalistic sample code that reproduces the problem:
from gi.repository import Gtk as gtk
from gi.repository import AppIndicator3 as appindicator
import os
import sys
def run_in_background():
pid = os.fork()
if pid != 0:
sys.exit(0)
def main():
indicator = appindicator.Indicator.new('an_indicator', gtk.STOCK_INFO, appindicator.IndicatorCategory.SYSTEM_SERVICES)
indicator.set_status(appindicator.IndicatorStatus.ACTIVE)
m = gtk.Menu()
indicator.set_menu(m)
gtk.main()
run_in_background()
if __name__ == "__main__":
main()
If I remove "run_in_background()", the indicator shows up immediatly, but if I introduce it, it takes about 10 to 15 seconds to show up.
Is there a way to address this problem? Why does it take so long for the indicator to show up after a fork?