Skip to content

Instantly share code, notes, and snippets.

@indriApollo
Created May 19, 2016 17:12
Show Gist options
  • Select an option

  • Save indriApollo/1b199ce959d6aa303cfe2144a407327a to your computer and use it in GitHub Desktop.

Select an option

Save indriApollo/1b199ce959d6aa303cfe2144a407327a to your computer and use it in GitHub Desktop.
from multiprocessing import Process, Value
def f(flag):
i = 0
while flag.value == 1:
i+=1
flag.value = i
if __name__ == '__main__':
flag = Value("i", 1)
p = Process(target=f, args=(flag,))
p.start()
input("Press enter to exit loop")
flag.value = 0
p.join()
print(flag.value)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment