This is (1) not possible at all (the "exact" part) and (2) not what Python fits well. If you really need precision microsecond execution, use C or ASM, but even closer than COpython's answer will be expected in two different processes within the agreed start time:
from multiprocessing import Process import os import datetime from time import time def func_1(title): now = datetime.datetime.now() print "hello, world" print "Current second: %d" % now.second print "Current microsecond: %d" % now.microsecond def func_2(name): now = datetime.datetime.now() print "Bye, world" print "Current second: %d" % now.second print "Current microsecond: %d" % now.microsecond def start_f1(name): while time() < start_time: pass func_1(name) def start_f2(name): while time() < start_time: pass func_2(name) if __name__ == '__main__': procs = [] procs.append(Process(target=start_f2, args=('bob',))) procs.append(Process(target=start_f1, args=('sir',))) start_time = time() + 10 map(lambda x: x.start(), procs) map(lambda x: x.join(), procs)
l4mpi source share