Skip to content

Instantly share code, notes, and snippets.

@hltbra
Created May 4, 2018 18:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hltbra/90a18cda67b458223dbd1e4a4627cabb to your computer and use it in GitHub Desktop.
Save hltbra/90a18cda67b458223dbd1e4a4627cabb to your computer and use it in GitHub Desktop.
PoC to demonstrate Copy-on-Write
bigobj = range(int(10e6))
print "waiting..."
def child():
print "waiting inside child"
time.sleep(10)
from multiprocessing import Process
p = Process(target=child, args=())
raw_input("press enter to start child")
p.start()
p.join()
print "quitting"
bigobj = range(int(10e6))
print "waiting..."
def child():
print "waiting inside child"
import time
#### modify `bigobj` #######
for i in xrange(len(bigobj)):
bigobj[i] += 1
############################
time.sleep(10)
from multiprocessing import Process
p = Process(target=child, args=())
raw_input("press enter to start child")
p.start()
p.join()
print "quitting"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment