def METHOD_NAME(duration=1):
    """run the Cocoa eventloop for the specified duration (seconds)"""
    _triggered.clear()
    NSApp = _NSApp()
    _stop_after(duration)
    msg(NSApp, n("run"))
    if not _triggered.is_set():
        # app closed without firing callback,
        # probably due to last window being closed.
        # Run the loop manually in this case,
        # since there may be events still to process (ipython/ipython#9734)
        CoreFoundation.CFRunLoopRun()