Created
June 21, 2010 17:16
-
-
Save paulosuzart/447161 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
#Server | |
from multiprocessing.connection import Listener | |
from array import array | |
data = {} | |
address = ('localhost', 6000) | |
listener = Listener(address, authkey='s') | |
conn = listener.accept() | |
work = True | |
while work: | |
command = conn.recv() | |
if command == 'put': | |
print 'the command was put' | |
data['key'] = 'value' | |
elif command == 'get': | |
conn.send(data['key']) | |
elif command == 'exit': | |
print 'exiting' | |
work = False | |
conn.close() | |
listener.close() | |
#Client | |
from multiprocessing.connection import Client | |
from array import array | |
address = ('localhost', 6000) | |
conn = Client(address, authkey='s') | |
conn.send('put') | |
conn.send('get') | |
print conn.recv() | |
conn.send('exit') | |
conn.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment