import multiprocessing, sys, datetime

print_lock = multiprocessing.Lock()
def safeprint(content):
  with print_lock:
    sys.stdout.write(("[" + str(multiprocessing.current_process().pid) + "] " + datetime.datetime.now().strftime('%H%M%S') + ": " + str(content) + '\r\n'))

import multiprocessing, sys, datetime

print_lock = multiprocessing.RLock()
def safeprint(content):
  string = "[" + str(multiprocessing.current_process().pid) + "] " + datetime.datetime.now().strftime('%H%M%S') + ": " + str(content) + '\r\n'
  with print_lock:
    sys.stdout.write(string)

Reduce the amount of time locking
Reduce the amount of time locking