Skip to content

Instantly share code, notes, and snippets.

@heynemann
Created January 3, 2012 01:15
Show Gist options
  • Save heynemann/1552950 to your computer and use it in GitHub Desktop.
Save heynemann/1552950 to your computer and use it in GitHub Desktop.
NAMED PIPE READING IMAGE
#!/usr/bin/python
# -*- coding: utf-8 -*-
import os
NAMED_PIPE = '/tmp/PIPE'
def main():
if not os.path.exists(NAMED_PIPE):
os.mkfifo(NAMED_PIPE)
try:
while True:
print "READING DATA..."
pipe = open(NAMED_PIPE, 'r')
data = pipe.read()
print data
finally:
pipe.close()
os.remove(NAMED_PIPE)
if __name__ == '__main__':
main()
#!/usr/bin/python
# -*- coding: utf-8 -*-
NAMED_PIPE = '/tmp/PIPE'
def main():
with open('rafael_amalia.jpg', 'r') as image:
pipe = open(NAMED_PIPE, 'w')
pipe.write(image.read())
if __name__ == '__main__':
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment