nodes: 0, module; 1, function_definition; 2, function_name:wait_for_vacancy; 3, parameters; 4, block; 5, identifier:self; 6, identifier:processor_type; 7, expression_statement; 8, with_statement; 9, comment:"""Waits for a particular processor type to have the capacity to
          handle additional transactions or until is_cancelled is True.
  
          Args:
              processor_type (ProcessorType): The family, and version of
                  the transaction processor.
  
          Returns:
              Processor
          """; 10, with_clause; 11, block; 12, with_item; 13, expression_statement; 14, if_statement; 15, expression_statement; 16, return_statement; 17, attribute; 18, call; 19, call; 20, block; 21, assignment; 22, identifier:processor; 23, identifier:self; 24, identifier:_condition; 25, attribute; 26, argument_list; 27, attribute; 28, argument_list; 29, raise_statement; 30, identifier:processor; 31, call; 32, attribute; 33, identifier:wait_for; 34, lambda; 35, attribute; 36, identifier:is_set; 37, call; 38, attribute; 39, argument_list; 40, identifier:self; 41, identifier:_condition; 42, parenthesized_expression; 43, identifier:self; 44, identifier:_cancelled_event; 45, identifier:WaitCancelledException; 46, argument_list; 47, subscript; 48, identifier:next_processor; 49, boolean_operator; 50, identifier:self; 51, identifier:processor_type; 52, call; 53, call; 54, attribute; 55, argument_list; 56, attribute; 57, argument_list; 58, identifier:self; 59, identifier:_processor_available; 60, identifier:processor_type; 61, attribute; 62, identifier:is_set; 63, identifier:self; 64, identifier:_cancelled_event
code: def wait_for_vacancy(self, processor_type):
          """Waits for a particular processor type to have the capacity to
          handle additional transactions or until is_cancelled is True.
  
          Args:
              processor_type (ProcessorType): The family, and version of
                  the transaction processor.
  
          Returns:
              Processor
          """
  
          with self._condition:
              self._condition.wait_for(lambda: (
                  self._processor_available(processor_type)
                  or self._cancelled_event.is_set()))
              if self._cancelled_event.is_set():
                  raise WaitCancelledException()
              processor = self[processor_type].next_processor()
              return processor