Skip to content

Instantly share code, notes, and snippets.

@colesbury
Created October 1, 2020 18:57
Show Gist options
  • Save colesbury/592169c75661c97ff2ecd9f76260134e to your computer and use it in GitHub Desktop.
Save colesbury/592169c75661c97ff2ecd9f76260134e to your computer and use it in GitHub Desktop.
import threading
from queue import Queue
import numpy as np
def thread1(queue):
queue.get().fill(5)
def thread2(queue):
queue.get().resize((1, 1))
def make_queue():
arr = np.random.randn(1000, 1000)
queue = Queue()
queue.put(arr)
queue.put(arr)
return queue
def main():
q = make_queue()
t1 = threading.Thread(target=thread1, args=(q,))
t2 = threading.Thread(target=thread2, args=(q,))
t1.start()
t2.start()
t1.join()
t2.join()
print('OK')
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment