OLD | NEW |
1 #!/usr/bin/python | 1 #!/usr/bin/python |
2 """ | 2 """ |
3 A class and functions used for running and controlling child processes. | 3 A class and functions used for running and controlling child processes. |
4 | 4 |
5 @copyright: 2008-2009 Red Hat Inc. | 5 @copyright: 2008-2009 Red Hat Inc. |
6 """ | 6 """ |
7 | 7 |
8 import os, sys, pty, select, termios, fcntl | 8 import os, sys, pty, select, termios, fcntl |
9 | 9 |
10 | 10 |
(...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
554 """ | 554 """ |
555 Kill all kvm_tail threads. | 555 Kill all kvm_tail threads. |
556 | 556 |
557 After calling this function no new threads should be started. | 557 After calling this function no new threads should be started. |
558 """ | 558 """ |
559 global _thread_kill_requested | 559 global _thread_kill_requested |
560 _thread_kill_requested = True | 560 _thread_kill_requested = True |
561 for t in threading.enumerate(): | 561 for t in threading.enumerate(): |
562 if hasattr(t, "name") and t.name.startswith("tail_thread"): | 562 if hasattr(t, "name") and t.name.startswith("tail_thread"): |
563 t.join(10) | 563 t.join(10) |
| 564 _thread_kill_requested = False |
564 | 565 |
565 | 566 |
566 class kvm_tail(kvm_spawn): | 567 class kvm_tail(kvm_spawn): |
567 """ | 568 """ |
568 This class runs a child process in the background and sends its output in | 569 This class runs a child process in the background and sends its output in |
569 real time, line-by-line, to a callback function. | 570 real time, line-by-line, to a callback function. |
570 | 571 |
571 See kvm_spawn's docstring. | 572 See kvm_spawn's docstring. |
572 | 573 |
573 This class uses a single pipe reader to read data in real time from the | 574 This class uses a single pipe reader to read data in real time from the |
(...skipping 629 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1203 @param timeout: The duration (in seconds) to wait until a match is | 1204 @param timeout: The duration (in seconds) to wait until a match is |
1204 found | 1205 found |
1205 @param internal_timeout: The timeout to pass to read_nonblocking | 1206 @param internal_timeout: The timeout to pass to read_nonblocking |
1206 @param print_func: A function to be used to print the data being read | 1207 @param print_func: A function to be used to print the data being read |
1207 (should take a string parameter) | 1208 (should take a string parameter) |
1208 """ | 1209 """ |
1209 (status, output) = self.get_command_status_output(command, timeout, | 1210 (status, output) = self.get_command_status_output(command, timeout, |
1210 internal_timeout, | 1211 internal_timeout, |
1211 print_func) | 1212 print_func) |
1212 return output | 1213 return output |
OLD | NEW |