Last active
November 13, 2017 12:56
-
-
Save justdoit0823/91c50f183f18eceea9c23bb78a7098b2 to your computer and use it in GitHub Desktop.
Simulate golang channel in Python.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import queue | |
| import threading | |
| w_queue = queue.Queue(maxsize=10) | |
| def foo(): | |
| w_queue.put('Hello, world') | |
| def main(): | |
| f_worker = threading.Thread(target=foo) | |
| f_worker.start() | |
| print(w_queue.get()) | |
| if __name__ == '__main__': | |
| main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment