Last active
July 30, 2022 00:23
-
-
Save zed/9334570 to your computer and use it in GitHub Desktop.
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
| #!/usr/bin/env python | |
| """Try to cause MemoryError by sending large data via multiprocessing.Pipe. | |
| Context: http://stackoverflow.com/q/22150703 | |
| """ | |
| from multiprocessing import Process, Pipe | |
| def send_big_data(conn): | |
| data = b"a" * (1 << 30) # 1GB | |
| conn.send(data) | |
| conn.close() # eof | |
| if __name__=="__main__": | |
| parent_conn, child_conn = Pipe() | |
| child = Process(target=send_big_data, args=(child_conn,)) | |
| child.start() | |
| child_conn.close() # child must be the only with it opened | |
| print(len(parent_conn.recv())) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment