MCPcopy Index your code
hub / github.com/cirosantilli/linux-kernel-module-cheat / _print_thread_safe

Method _print_thread_safe

shell_helpers.py:46–56  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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 = []

Callers 1

print_cmdMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected