Python sucks: a naive print adds a bunch of random spaces to stdout, and then copy pasting the command fails. https://stackoverflow.com/questions/3029816/how-do-i-get-a-thread-safe-print-in-python-2-6 The initial use case was test-gdb which must create a thread for G
(cls, string)
| 44 | |
| 45 | @classmethod |
| 46 | def _print_thread_safe(cls, string): |
| 47 | ''' |
| 48 | Python sucks: a naive print adds a bunch of random spaces to stdout, |
| 49 | and then copy pasting the command fails. |
| 50 | https://stackoverflow.com/questions/3029816/how-do-i-get-a-thread-safe-print-in-python-2-6 |
| 51 | The initial use case was test-gdb which must create a thread for GDB to run the program in parallel. |
| 52 | ''' |
| 53 | cls._print_lock.acquire() |
| 54 | sys.stdout.write(string + '\n') |
| 55 | sys.stdout.flush() |
| 56 | cls._print_lock.release() |
| 57 | |
| 58 | def add_newlines(self, cmd): |
| 59 | out = [] |