Skip to content

Instantly share code, notes, and snippets.

@paulosuzart
Created June 21, 2010 17:16
Show Gist options
  • Save paulosuzart/447161 to your computer and use it in GitHub Desktop.
Save paulosuzart/447161 to your computer and use it in GitHub Desktop.
#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