MCPcopy Create free account
hub / github.com/bugy/script-server / _MockProcessWrapper

Class _MockProcessWrapper

src/tests/test_utils.py:548–606  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

546
547
548class _MockProcessWrapper(ProcessWrapper):
549 def __init__(self, executor, command, working_directory, env_variables):
550 super().__init__(command, working_directory, env_variables)
551
552 self.exit_code = None
553 self.finished = False
554 self.process_id = int.from_bytes(uuid.uuid1().bytes, byteorder='big')
555 self.finish_condition = threading.Condition()
556
557 def get_process_id(self):
558 return self.process_id
559
560 # method for tests
561 def finish(self, exit_code):
562 if self.is_finished():
563 raise Exception('Cannot finish a script twice')
564 self.__finish(exit_code)
565
566 # method for tests
567 def write_output(self, output):
568 self._write_script_output(output)
569
570 def stop(self):
571 self.__finish(9)
572
573 def kill(self):
574 self.__finish(15)
575
576 def __finish(self, exit_code):
577 if self.finished:
578 return
579
580 with self.finish_condition:
581 self.exit_code = exit_code
582 self.finished = True
583 self.output_stream.close()
584 self.finish_condition.notify_all()
585
586 self.notify_finish_thread.join()
587
588 def is_finished(self):
589 return self.finished
590
591 def get_return_code(self):
592 return self.exit_code
593
594 def pipe_process_output(self):
595 pass
596
597 def start_execution(self, command, working_directory):
598 pass
599
600 def wait_finish(self):
601 with self.finish_condition:
602 while not self.finished:
603 self.finish_condition.wait(0.01)
604
605 def write_to_input(self, value):

Callers 2

create_processMethod · 0.90
create_processMethod · 0.90

Calls

no outgoing calls

Tested by 2

create_processMethod · 0.72
create_processMethod · 0.72