Skip to content

Commit 14c8304

Browse files
committed
Add queue example
1 parent c2c7fee commit 14c8304

1 file changed

Lines changed: 14 additions & 0 deletions

File tree

‎Doc/library/concurrent.interpreters.rst‎

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -430,3 +430,17 @@ Creating an interpreter and running code in it::
430430

431431
t = interp.call_in_thread(run)
432432
t.join()
433+
434+
Communicating between interpreters with a queue::
435+
436+
from concurrent import interpreters
437+
438+
interp = interpreters.create()
439+
queue = interpreters.create_queue()
440+
441+
def worker(queue):
442+
queue.put('spam!')
443+
444+
t = interp.call_in_thread(worker, queue)
445+
print(queue.get())
446+
t.join()

0 commit comments

Comments
 (0)