Created
          January 7, 2016 22:33 
        
      - 
      
- 
        Save jaysudodeveloper/db92c17dac8e29835222 to your computer and use it in GitHub Desktop. 
Revisions
- 
        Jay Jamieson created this gist Jan 7, 2016 .There are no files selected for viewingThis file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,19 @@ # wait for incoming data to consume with a for loop def consume(): while True: data = yield consumer = data # Aliase the data variable to ensure the generator stays "charged" for i in consumer: # consume the data and return back to the while loop print i # Just a basic generator object for proof of concept def in_gen(x): for i in range(x): yield i consumer = consume() data = in_gen(5) consumer.send(None) # precharge the generator before sending data. this is a must # as generator objescts dont start when intantiated consumer.send(data) 
 Jay Jamieson
              created
            
            this gist
            
              Jay Jamieson
              created
            
            this gist