-
Notifications
You must be signed in to change notification settings - Fork 0
classtools.message
sikvelsigma edited this page Aug 18, 2022
·
4 revisions
- class
MessageThread
Making an instance of MessageThread launches a separate thread which will output messages using print_func function provided on init with method print. This is useful if there're multiple threads outputing messages which may result in a disjoined output
from pyuseful.classtools.message import MessageThread
def some_print(msg):
print(f"some_print: {msg}")
msg = MessageThread(print_func=print)
# will print "some_print: hello"
msg.print("hello")
# wait for all messages to print
msg.join()