def add_import_trigger(name, trigger):
    """Register a callable to be called immediately after the module of the given name
    is imported. If the module has already been imported, the trigger is called
    immediately."""

    if name in sys.modules:
        trigger()
    else:
        import_triggers[name] = trigger
Register a callable to be called immediately after the module of the given name
    is imported. If the module has already been imported, the trigger is called
    immediately.
product/runtime/src/main/python/java/android/importer.py