original_docstring: Wait for and handle a single request.
docstring: Wait for and handle a single request.
docstring_tokens: Wait for and handle a single request .
code: async def handle_request():
              """Wait for and handle a single request."""
              nonlocal process, process_task
              logger.debug("Waiting for request")
              request = await queue.get()
  
              if request.name == RequestTypes.run_process:
                  assert process is None, "Process must not have been started"
                  process_state = request.contents
                  process = self._start_callback(process_state)
                  process_task = asyncio.create_task(process.wait())
                  pid = process.pid
                  logger.debug("Running process in handler: %d", pid)
                  await connection.send(Response(pid))
  
              elif request.name == RequestTypes.wait_process_done:
                  assert process is not None, "Process must have been started"
                  logger.debug("Waiting for process to exit")
                  # We don't want the process.wait() task to be cancelled in case
                  # our connection gets broken.
                  exitcode = await asyncio.shield(process_task)
                  logger.debug("Result: %d", exitcode)
                  await connection.send(Response(exitcode))
  
              return True
code_tokens: async def handle_request ( ) : nonlocal process , process_task logger . debug ( "Waiting for request" ) request = await queue . get ( ) if request . name == RequestTypes . run_process : assert process is None , "Process must not have been started" process_state = request . contents process = self . _start_callback ( process_state ) process_task = asyncio . create_task ( process . wait ( ) ) pid = process . pid logger . debug ( "Running process in handler: %d" , pid ) await connection . send ( Response ( pid ) ) elif request . name == RequestTypes . wait_process_done : assert process is not None , "Process must have been started" logger . debug ( "Waiting for process to exit" ) exitcode = await asyncio . shield ( process_task ) logger . debug ( "Result: %d" , exitcode ) await connection . send ( Response ( exitcode ) ) return True
short_docstring: Wait for and handle a single request.
short_docstring_tokens: Wait for and handle a single request .
comment: """Wait for and handle a single request."""$SEP$# We don't want the process.wait() task to be cancelled in case$SEP$# our connection gets broken.