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)

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'))

--- 
+++ 
@@ -1,6 +1,7 @@
 import multiprocessing, sys, datetime
 
-print_lock = multiprocessing.Lock()
+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(("[" + str(multiprocessing.current_process().pid) + "] " + datetime.datetime.now().strftime('%H%M%S') + ": " + str(content) + '\r\n'))
+    sys.stdout.write(string)
Reduce the amount of time locking