{
  "__type": "IngestedDoc",
  "__tag": 4010,
  "_content": {},
  "_ordered_sections": [],
  "item_file": null,
  "item_line": null,
  "item_type": null,
  "aliases": [],
  "example_section_data": {
    "__type": "Section",
    "__tag": 4015,
    "children": [],
    "title": [],
    "level": 0,
    "target": null
  },
  "see_also": [],
  "signature": null,
  "references": null,
  "qa": "pending-kernels",
  "arbitrary": [
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Emphasis",
              "__tag": 4047,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "Added in 7.1.0"
                }
              ]
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "In scenarios where an kernel takes a long time to start (e.g. kernels running remotely), it can be advantageous to immediately return the kernel's model and ID from key methods like "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ".start_kernel()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ".shutdown_kernel()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". The kernel will continue its task without blocking other managerial actions."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "This intermediate state is called a "
            },
            {
              "__type": "Strong",
              "__tag": 4048,
              "children": [
                {
                  "__type": "Text",
                  "__tag": 4046,
                  "value": "\"pending kernel\""
                }
              ]
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Pending Kernels"
        }
      ],
      "level": 0,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ".start_kernel()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ".shutdown_kernel()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is called, a "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "Future"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is created under the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "KernelManager.ready"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " property. This property can be awaited anytime to ensure that the kernel moves out of its pending state, e.g.:"
            }
          ]
        },
        {
          "__type": "Code",
          "__tag": 4050,
          "value": "# await a Kernel Manager's `.ready` property to\n# block further action until the kernel is out\n# of its pending state.\nawait kernel_manager.ready",
          "execution_status": null,
          "out": ""
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "Once the kernel is finished pending, "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ".ready.done()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will be "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "True"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " and either 1) "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ".ready.result()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will return "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "None"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " or 2) "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": ".ready.exception()"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " will return a raised exception"
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "How they work"
        }
      ],
      "level": 1,
      "target": null
    },
    {
      "__type": "Section",
      "__tag": 4015,
      "children": [
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "The most common way to interact with pending kernels is through the `` MultiKernelManager``—the object that manages a collection of kernels—by setting its "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "use_pending_kernels"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " trait to "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "True"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ". Pending kernels are \"opt-in\"; they are not used by default in the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "MultiKernelManager"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "."
            }
          ]
        },
        {
          "__type": "Paragraph",
          "__tag": 4045,
          "children": [
            {
              "__type": "Text",
              "__tag": 4046,
              "value": "When "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "use_pending_kernels"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": " is "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "True"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ", the following changes are made to the "
            },
            {
              "__type": "InlineCode",
              "__tag": 4051,
              "value": "MultiKernelManager"
            },
            {
              "__type": "Text",
              "__tag": 4046,
              "value": ":"
            }
          ]
        },
        {
          "__type": "BulletList",
          "__tag": 4053,
          "ordered": true,
          "start": 1,
          "children": [
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "InlineCode",
                            "__tag": 4051,
                            "value": "start_kernel"
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": " and "
                          },
                          {
                            "__type": "InlineCode",
                            "__tag": 4051,
                            "value": "stop_kernel"
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": " return immediately while running the"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "pending task in a background thread."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": "The following methods raise a "
                          },
                          {
                            "__type": "InlineCode",
                            "__tag": 4051,
                            "value": "RuntimeError"
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": " if a kernel is pending:"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "BulletList",
                          "__tag": 4053,
                          "ordered": false,
                          "start": 1,
                          "children": [
                            {
                              "__type": "ListItem",
                              "__tag": 4054,
                              "children": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "InlineCode",
                                      "__tag": 4051,
                                      "value": "restart_kernel"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "__type": "ListItem",
                              "__tag": 4054,
                              "children": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "InlineCode",
                                      "__tag": 4051,
                                      "value": "interrupt_kernel"
                                    }
                                  ]
                                }
                              ]
                            },
                            {
                              "__type": "ListItem",
                              "__tag": 4054,
                              "children": [
                                {
                                  "__type": "Paragraph",
                                  "__tag": 4045,
                                  "children": [
                                    {
                                      "__type": "InlineCode",
                                      "__tag": 4051,
                                      "value": "shutdown_kernel"
                                    }
                                  ]
                                }
                              ]
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            },
            {
              "__type": "ListItem",
              "__tag": 4054,
              "children": [
                {
                  "__type": "DefList",
                  "__tag": 4033,
                  "children": [
                    {
                      "__type": "DefListItem",
                      "__tag": 4037,
                      "dt": {
                        "__type": "Paragraph",
                        "__tag": 4045,
                        "children": [
                          {
                            "__type": "InlineCode",
                            "__tag": 4051,
                            "value": "shutdown_all"
                          },
                          {
                            "__type": "Text",
                            "__tag": 4046,
                            "value": " will wait for all pending kernels to become ready before"
                          }
                        ]
                      },
                      "dd": [
                        {
                          "__type": "Paragraph",
                          "__tag": 4045,
                          "children": [
                            {
                              "__type": "Text",
                              "__tag": 4046,
                              "value": "attempting to shut them down."
                            }
                          ]
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        }
      ],
      "title": [
        {
          "__type": "Text",
          "__tag": 4046,
          "value": "Using pending kernels"
        }
      ],
      "level": 1,
      "target": null
    }
  ],
  "local_refs": []
}