Skip to content

Instantly share code, notes, and snippets.

@psyomn
Last active August 29, 2015 14:20
Show Gist options
  • Select an option

  • Save psyomn/c04ad560f4cf09557ab7 to your computer and use it in GitHub Desktop.

Select an option

Save psyomn/c04ad560f4cf09557ab7 to your computer and use it in GitHub Desktop.
send messages using multiprocessing lib in python
import sys
from multiprocessing.connection import Client
if len(sys.argv) == 1:
print "Usage:"
print " sendmsg.py <host> <port> <message>"
print " sendmsg.py <message> (default port:5000, host:localhost)"
args = sys.argv[1:]
if len(args) >= 3:
host = args[0]
port = int(args[1])
mesg = args[2]
else:
host = 'localhost'
port = 5000
mesg = args[0]
address = (host, port)
conn = Client(address)
conn.send_bytes(mesg)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment