PEP 554: Fix the examples. (#496)

This commit is contained in:
Eric Snow 2017-12-06 10:06:56 -07:00 committed by GitHub
parent 8c96ef61a6
commit 99d92e2813
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 21 additions and 10 deletions

View File

@ -220,7 +220,10 @@ Synchronize using a channel
print("during")
reader.close()
"""),
reader=r))
shared=dict(
reader=r,
),
)
t = threading.Thread(target=run)
print('before')
t.start()
@ -244,7 +247,11 @@ Sharing a file descriptor
print(line)
writer.send(b'')
"""),
reader=r1, writer=s2)
shared=dict(
reader=r,
writer=s2,
),
)
t = threading.Thread(target=run)
t.start()
with open('spamspamspam') as infile:
@ -262,7 +269,10 @@ Passing objects via marshal
interp.run(tw.dedent("""
import marshal
"""),
reader=r)
shared=dict(
reader=r,
),
)
def run():
interp.run(tw.dedent("""
data = reader.recv()
@ -271,14 +281,13 @@ Passing objects via marshal
do_something(obj)
data = reader.recv()
reader.close()
"""),
reader=r)
"""))
t = threading.Thread(target=run)
t.start()
for obj in input:
data = marshal.dumps(obj)
s.send(data)
s.send(b'')
s.send(None)
Passing objects via pickle
--------------------------
@ -290,7 +299,10 @@ Passing objects via pickle
interp.run(tw.dedent("""
import pickle
"""),
reader=r)
shared=dict(
reader=r,
),
)
def run():
interp.run(tw.dedent("""
data = reader.recv()
@ -299,14 +311,13 @@ Passing objects via pickle
do_something(obj)
data = reader.recv()
reader.close()
"""),
reader=r)
"""))
t = threading.Thread(target=run)
t.start()
for obj in input:
data = pickle.dumps(obj)
s.send(data)
s.send(b'')
s.send(None)
Running a module
----------------