<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 def patch_all():
 """ Runs all patches. This function ensures that a second invocation has no effect. """

    global _patched

    if _patched:
        return
    _patched = True

    patch_default_retcodes()
    patch_worker_run_task()
    patch_worker_factory()
    patch_keepalive_run()
    patch_cmdline_parser()

    logger.debug("applied law-specific luigi patches")