Last active
February 10, 2016 19:27
-
-
Save martindurant/143fcf52f766e38f8eca to your computer and use it in GitHub Desktop.
This file contains 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 socket | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.connect((socket.gethostname(), 8001)) | |
while True: | |
text = input() + '\n' | |
s.send(text.encode()) |
This file contains 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 socket | |
import distributed | |
from collections import Counter | |
e = distributed.Executor("localhost:8786") | |
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) | |
s.bind((socket.gethostname(), 8001)) | |
s.listen(1) | |
(clientsocket, address) = s.accept() | |
f = clientsocket.makefile() | |
count = e.submit(Counter) | |
while True: | |
out = f.readline() | |
if out: | |
count = e.submit(lambda x, y: x + Counter(y), count, out.split()) | |
print(count.result()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment