Skip to content

Instantly share code, notes, and snippets.

@martindurant
Last active February 10, 2016 19:27
Show Gist options
  • Save martindurant/143fcf52f766e38f8eca to your computer and use it in GitHub Desktop.
Save martindurant/143fcf52f766e38f8eca to your computer and use it in GitHub Desktop.
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())
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