[&] : capture by reference , all automatic storage duration variable declared in th reaching scope
[=] : capture by value, a value is copied
[x,&y] : capture x by value and y by a reference explicitly
| from jamo import h2j, j2hcj, j2h | |
| def doSomeThing( data , length ) : | |
| if length == 2 : | |
| return j2h( data[0] , data[1] ) | |
| elif length == 3: | |
| return j2h( data[0] , data[1] , data[2] ) | 
| pip install jamo | 
[&] : capture by reference , all automatic storage duration variable declared in th reaching scope
[=] : capture by value, a value is copied
[x,&y] : capture x by value and y by a reference explicitly
| wget http://download.redis.io/redis-stable.tar.gz | |
| tar xvf redis-stable.tar.gz | |
| make | |
| sudo make install | |
| redis-server --protected-mode no | 
| # | |
| # redis-server --protected-mode no | |
| # | |
| import redis | |
| r = redis.Redis(host='192.168.1.48', port=6379, db=0) | |
| r.set('blackfalcon1', 'helloworld1') | |
| r.set('blackfalcon2', 'helloworld2') | 
| import redis | |
| import time | |
| def read_messageq(): | |
| r = redis.StrictRedis(host='192.168.1.48', port=6379, db=0) | |
| p = r.pubsub() | |
| p.subscribe('startScripts') | |
| PAUSE = True | 
| import redis | |
| def send_messageq(): | |
| r = redis.StrictRedis(host='192.168.1.48', port=6379, db=0) | |
| p = r.pubsub() | |
| print("Starting main scripts...") | |
| r.publish('startScripts', 'START') | 
| #!/usr/bin/env python | |
| from gevent import monkey | |
| monkey.patch_all() # Patch everything | |
| import gevent | |
| import time | |
| class Hub(object): | |
| """A simple reactor hub... In async!""" | 
| import redis | |
| def send_messageq(): | |
| r = redis.StrictRedis(host='192.168.1.48', port=6379, db=0) | |
| p = r.pubsub() | |
| print("Starting main scripts...") | |
| r.publish('awesome', 'hello') | |
| print("Done") | 
| gevent | |
| redis |