8000 Updates for PEP 554. by ericsnowcurrently · Pull Request #419 · python/peps · GitHub
[go: up one dir, main page]

Skip to content

Updates for PEP 554. #419

New issue 8000

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 18 commits into from
Sep 12, 2017
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

8000
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Fill out the remaining examples.
  • Loading branch information
ericsnowcurrently committed Sep 12, 2017
commit 2c95da229f99507c84e04940f343ca8c7f1f6fab
47 changes: 45 additions & 2 deletions pep-0554.rst
Original file line number Diff line number Diff line change
Expand Up @@ -303,12 +303,55 @@ Synchronize using a FIFO
Sharing a file descriptor
-------------------------

TBD
::

interp = interpreters.create()
writer = interp.add_recv_fifo('spam')
reader = interp.add_send_fifo('done')
def run():
interp.run("""if True:
import interpreters
interp = interpreters.get_current()
reader = interp.get_fifo('spam')
writer = interp.get_fifo('done')
fd = reader.pop()
for line in os.fdopen(fd):
print(line)
writer.push(None)
""")
t = threading.Thread(target=run)
t.start()
with open('spamspamspam') as infile:
writer.push(infile.fileno())
reader.pop()

Passing objects via pickle
--------------------------

TBD
::

interp = interpreters.create()
writer = interp.add_recv_fifo('spam')
interp.run("""if True:
import pickle
import interpreters
interp = interpreters.get_current()
reader = interp.get_fifo('spam')
""")
def run():
interp.run("""if True:
data = reader.pop()
while data is not None:
obj = pickle.loads(data)
do_something(obj)
data = reader.pop()
""")
t = threading.Thread(target=run)
t.start()
for obj in input:
data = pickle.dumps(obj)
writer.push(data)
writer.push(None)


Rationale
Expand Down
0