class_docstr: Event loop for posix systems (Linux, Mac os X).
docstr: Run a long running function in a background thread.
  (This is recommended for code that could block the event loop.)
  Similar to Twisted's ``deferToThread``.
docstr_tok: ["Run","a","long","running","function","in","a","background","thread",".","(","This","is","recommended","for","code","that","could","block","the","event","loop",".",")","Similar","to","Twisted","'s","``","deferToThread","``","."]
code: def run_in_executor(self, callback):
      """
      Run a long running function in a background thread.
      (This is recommended for code that could block the event loop.)
      Similar to Twisted's ``deferToThread``.
      """
  
      # Wait until the main thread is idle.
      # We start the thread by using `call_from_executor`. The event loop
      # favours processing input over `calls_from_executor`, so the thread
      # will not start until there is no more input to process and the main
      # thread becomes idle for an instant. This is good, because Python
      # threading favours CPU over I/O -- an autocompletion thread in the
      # background would cause a significantly slow down of the main thread.
      # It is mostly noticable when pasting large portions of text while
      # having real time autocompletion while typing on.
      def start_executor():
          threading.Thread(target=callback).start()
  
      self.call_from_executor(start_executor)
  
imports: from __future__ import unicode_literals
  import fcntl
  import os
  import signal
  import threading
  import time
  from prompt_toolkit.terminal.vt100_input import InputStream
  from prompt_toolkit.utils import DummyContext, in_main_thread
  from prompt_toolkit.input import Input
  from .base import EventLoop, INPUT_TIMEOUT
  from .callbacks import EventLoopCallbacks
  from .inputhook import InputHookContext
  from .posix_utils import PosixStdinReader
  from .utils import TimeIt
  from .select import AutoSelector, Selector, fd_to_int
label_desc: Use image node_id 5 for calling the PosixEventLoop obj's underlying member method code with example usage: obj.run_in_executor(callback) without return types