def f(q):
    q.put('Hello')
q.put('Bye')
q.put(None)
if __name__ == '__main__':
    q = Queue()
p = Process(target=f, args=(q,))
p.start()
with open('file.txt', 'w') as fp:
    while True:
        pass
Python Multiprocessing using Queue to write to same file