本文整理汇总了Python中redis.publish函数的典型用法代码示例。如果您正苦于以下问题:Python publish函数的具体用法?Python publish怎么用?Python publish使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了publish函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: inbox
def inbox(ws):
while not ws.closed:
gevent.sleep(0.1)
message = ws.receive()
if message:
redis.publish('chat', message)
开发者ID:Alex961120,项目名称:louplus-python,代码行数:7,代码来源:ws.py
示例2: worker
def worker (self):
print "simulador worker"
while 1:
msgFromController = self.ser.readline().strip()
if (msgFromController=="#estadoPlanta!"):
self.planta.ref = xref
# y, ref
# Tests
#(a,b) = genRandomPairs()
# envia (y , ref)
self.iteration += 1
myTime = time.time()
estado = {'outs':[self.planta.out, self.planta.ref - self.planta.out, self.planta.actu], 'ts':myTime, 'msg_id':self.iteration}
redis.publish (toRedisOut, json.dumps(estado))
print "estado planta: ", estado
msg = self.armaMsg(floatToDigital(self.planta.out), floatToDigital(self.planta.ref))
self.sendMessageToController (msg)
else:
try:
actu = msgFromController.strip('#').strip('!')
self.planta.iterate( digitalToFloat(int(actu)))
except:
pass
开发者ID:lmpizarro,项目名称:apuntes-python-cientifico,代码行数:27,代码来源:comSer.py
示例3: exit_app
def exit_app(self, redis, root, event=None):
root.destroy()
j = {'action': 'quit'}
jstr = json.dumps(j)
for channel in ['uwtec:front', 'uwtec:rear', 'uwtec:side']:
redis.publish(channel, jstr)
开发者ID:zooliet,项目名称:UWTracking,代码行数:7,代码来源:gui_controller.py
示例4: main
def main():
"""
main entry point for the program
The return value will be the returncode for the program
"""
_initialize_stderr_logging()
log = logging.getLogger("main")
log.info("program starts")
args = _parse_commandline()
redis = _create_redis_connection()
start_time = time.time()
elapsed_time = 0.0
while elapsed_time < args.test_duration:
try:
key, count = _store_one_key(args)
except Exception:
log.exception("_store_one_key")
return 1
# there is some latency in file_name_set_manager
# so we pause before notifying the consumer
interval = random.uniform(args.min_key_interval, args.max_key_interval)
time.sleep(interval)
redis_key = "_".join([args.redis_prefix, key])
message = "{0} {1}".format(redis_key, count)
redis.publish(args.notification_channel, message)
elapsed_time = time.time() - start_time
log.info("program completes return code = 0")
return 0
开发者ID:SpiderOak,项目名称:file_name_set_manager,代码行数:34,代码来源:test_producer.py
示例5: zoom_x1
def zoom_x1(self, redis, channel, button, event=None):
button.config(state='normal', background='orange')
button.after(600, lambda: button.config(state='normal', background='#d9d9d9'))
j = {'action': 'zoom_x1'}
jstr = json.dumps(j)
redis.publish(channel, jstr)
开发者ID:zooliet,项目名称:UWTracking,代码行数:7,代码来源:gui_controller.py
示例6: autozoom
def autozoom(self, redis, channel, autozoom, event=None):
if autozoom.get():
j = {'action': 'autozoom', 'value': True}
else:
j = {'action': 'autozoom', 'value': False}
jstr = json.dumps(j)
redis.publish(channel, jstr)
开发者ID:zooliet,项目名称:UWTracking,代码行数:7,代码来源:gui_controller.py
示例7: edit
def edit(request, room):
was_private = room.is_private
if request.method == 'POST':
form = RoomForm(request.POST, instance=room)
if form.is_valid():
form.save(commit=False)
room.save()
if room.is_private and not was_private:
redis = create_redis_connection()
redis.publish('web_channel', 'room_private:' + str(room.id))
try:
redis.hdel(redis_room_key(room.id), *redis.hkeys(redis_room_key(room.id)))
except:
pass
return HttpResponseRedirect(request.get_full_path())
else:
form = RoomForm(instance=room)
response_data = { 'form' : form }
if room.is_private:
response_data['invited_users'] = room.invited.order_by('username').all()
response_data['users'] = User.objects.exclude(pk=room.owner.id).exclude(rooms__pk=room.id).order_by('username').all()
return response_data
开发者ID:dsizov,项目名称:kontakt-game,代码行数:29,代码来源:views.py
示例8: inbox
def inbox(ws):
# Receives incoming POST requests and inserts them into Redis.
while ws.socket is not None:
# Sleep to prevent *constant* context-switches.
gevent.sleep(0.1)
message = ws.receive()
redis.publish(DATABASE_BROADCASTER, message)
开发者ID:dtangster,项目名称:cs157a,代码行数:7,代码来源:library.py
示例9: inbox
def inbox(ws):
"""Receives incoming chat messages, inserts them into Redis."""
while ws.socket is not None:
# Sleep to prevent *contstant* context-switches.
gevent.sleep(0.1)
message = ws.receive()
#print message
#sys.stdout.flush()
if message:
jsonMessage = json.loads(message)
#NLTK version analysis
#message = message.replace("}", ',\"' + 'length\":\"' + str( getLengthOfMessage(message) )+ '\"' + ',\"' + 'neg\":\"' + str(getNegEmotionValue(jsonMessage["text"])) + '\"' + ',\"' + 'pos\":\"' + str(getPosEmotionValue(jsonMessage["text"])) + '\"' + '}' )
#SentiStrength analysis
text = jsonMessage["text"]
sentistrength_result = RateSentiment(text)
name = jsonMessage["handle"]
posV = sentistrength_result[:1]
negV = sentistrength_result[2:]
emotionV = getEmotionValueFrom( int(posV), int(negV) )
message = message.replace("}", ',\"' + 'length\":\"' + str( getLengthOfMessage(message) )+ '\"' + ',\"' + 'neg\":\"' + sentistrength_result[2:] + '\"' + ',\"' + 'pos\":\"' + sentistrength_result[:1] + '\"' + '}' )
print emotionV
sys.stdout.flush()
app.logger.info(u'Inserting message: {}'.format(message))
#post the message to given channel
redis.publish(REDIS_CHAN, message)
chats.saveToFirebase( name, text, emotionV )
开发者ID:mw10104587,项目名称:GameIM-CHIPlay,代码行数:29,代码来源:chat.py
示例10: offset_madness
def offset_madness():
offset = 1
while offset:
offset = raw_input("Add offset (ms) >> ")
if offset:
offset = float(offset)
data = {"offsetInMillis": offset}
redis.publish('song-adjust', json.dumps(data))
开发者ID:jjsub,项目名称:hackdanceville6,代码行数:8,代码来源:test_sound_master.py
示例11: rate_adjust
def rate_adjust():
rate = 1.
while rate:
rate = raw_input('New rate >> ')
if rate:
rate = float(rate)
data = {"rateAdjustFactor": rate}
redis.publish('song-adjust', json.dumps(data))
开发者ID:jjsub,项目名称:hackdanceville6,代码行数:8,代码来源:test_sound_master.py
示例12: outbox
def outbox(ws):
chat.register(ws)
redis.publish('chat', json.dumps(dict(
username='New user come in, people count',
text=len(chat.clients)
)))
while not ws.closed:
gevent.sleep(0.1)
开发者ID:Alex961120,项目名称:louplus-python,代码行数:8,代码来源:ws.py
示例13: main
def main():
client = KafkaClient("localhost:9092")
consumer = SimpleConsumer(client, "test-group", "twitter_raw")
consumer.seek(0,2)
num = 0
for message in consumer:
print "redis publish:", num
num+=1
try:
data_depickled = pickle.loads(message.message.value.decode('utf-8'))
except Exception, e:
continue
# print data_depickled
# {
# 'text':'@_LulaMoore me hamas perra',
# 'created_at':datetime.datetime(2015, 10, 9, 23, 36, 49),
# 'source':u'Twitter Web Client',
# 'lang:':u'es',
# 'place':{
# 'country_code':u'AR',
# 'coordinates':[
# [
# -68.176283,
# -38.984724
# ],
# [
# -68.176283,
# -38.921051
# ],
# [
# -68.015162,
# -38.921051
# ],
# [
# -68.015162,
# -38.984724
# ]
# ]
# },
# 'user':{
# 'statuses_count':15067,
# 'name':u'Dama negra *\uffe6*',
# 'friends_count':390,
# 'created_at':datetime.datetime(2014, 3, 15,2,37, 10),
# 'profile_image_url': u'http://pbs.twimg.com/profile_images/652333268256313344/x9K9Nlys_normal.jpg',
# 'followers_count':384,
# 'id':2390242428
# },
# 'id':652628813935980544
# }
### process data here ###
# text = data_depickled['text']
filtered_data = data_filter(data_depickled)
data_pickled = pickle.dumps(filtered_data)
redis.publish('tweets_processed', data_pickled)
开发者ID:krist-jin,项目名称:tweets-map,代码行数:57,代码来源:simpleSub.py
示例14: inbox
def inbox(ws):
"""Receives incoming chat messages, inserts them into Redis."""
while ws.socket is not None:
# Sleep to prevent *contstant* context-switches.
gevent.sleep(0.1)
message = ws.receive()
if message:
app.logger.info(u'Inserting message: %s'%message)
redis.publish(MAIN_CHAN, message)
开发者ID:fmassot,项目名称:babbling-with-websockets,代码行数:10,代码来源:babbler.py
示例15: inbox
def inbox(ws):
"""Receives incoming chat messages, inserts them into Redis."""
while not ws.closed:
# Sleep to prevent *constant* context-switches.
gevent.sleep(0.1)
message = ws.receive()
if message:
app.logger.info(u'Inserting message: {}'.format(message))
redis.publish(REDIS_CHAN, message)
开发者ID:tegeling,项目名称:raspiforce-monitor,代码行数:10,代码来源:chat.py
示例16: incr
def incr(self, name, timestamp=None, value=1, filters={}):
timestamp = timestamp or datetime.datetime.now()
try:
redis = self.redis
redis.sadd(self.data_key, self.serialize("incr", name, timestamp, value, filters))
redis.publish(self.channel, json.dumps({"a": "notification"}))
except Exception, e:
print(e)
logger.warn(e)
开发者ID:GottWall,项目名称:stati-redis-python,代码行数:10,代码来源:client.py
示例17: inbox
def inbox(ws):
"""Receives incoming chat messages, inserts them into Redis."""
while ws.socket is not None:
# Sleep to prevent *contstant* context-switches.
gevent.sleep(0.1)
message = ws.receive()
if message:
app.logger.info('Inserting message: {}'.format(message.encode('utf-8')))
redis.publish(REDIS_CHAN, message)
开发者ID:ipdae,项目名称:python-websockets-chat,代码行数:10,代码来源:chat.py
示例18: inbox
def inbox(ws):
"""Receives incoming messages from java, inserts them into Redis."""
while not ws.closed:
# Sleep to prevent *constant* context-switches.
gevent.sleep(0.1)
message = ws.receive()
if message:
app.logger.info(u'Incoming message from java: {}'.format(message))
redis.publish(REDIS_CHAN, json.dumps({'handle' : 'java', 'text':message}))
开发者ID:accumsan,项目名称:py,代码行数:10,代码来源:app.py
示例19: setup
def setup(self, match):
map_name = match.mapp.name
redis.publish("server-%s" % self.id, json.dumps({
"tag": "match",
"map": map_name,
"id": match.id,
"players": "|".join(map(lambda i: str(convert_steamid(i.steamid)), match.getPlayers())),
"teama": "|".join(map(lambda i: str(convert_steamid(i.steamid)), match.getTeamA())),
"teamb": "|".join(map(lambda i: str(convert_steamid(i.steamid)), match.getTeamB()))
}))
开发者ID:b1naryth1ef,项目名称:GoPlayNao,代码行数:10,代码来源:database.py
示例20: recording
def recording(self, redis, channel, button, event=None):
if button.config('background')[-1] == '#d9d9d9':
button.config(state='normal', relief='raised', background='orange')
j = {'action': 'start_recording'}
else:
button.config(background='#d9d9d9')
# button.bind('<Enter>', lambda event, b=button: b.config(background='#d9d9d9'))
j = {'action': 'stop_recording'}
jstr = json.dumps(j)
redis.publish(channel, jstr)
开发者ID:zooliet,项目名称:UWTracking,代码行数:11,代码来源:gui_controller.py
注:本文中的redis.publish函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论