IRC Logs for #circuits Monday, 2015-03-09

*** Osso has joined #circuits01:30
*** Osso has quit IRC01:35
*** Osso has joined #circuits03:19
*** Osso has quit IRC03:24
*** Osso has joined #circuits05:08
*** Osso has quit IRC05:13
*** green1 has joined #circuits05:49
*** green1 has quit IRC06:47
*** Osso has joined #circuits06:57
*** Osso has quit IRC07:01
*** Osso has joined #circuits07:40
*** tariq786 has quit IRC11:33
*** tariq786 has joined #circuits11:35
*** kwmiebach has joined #circuits14:25
rogeriobastoshi, is there any example of poll use ?14:35
rogeriobastosI'm new in circuits14:35
*** RNeville has joined #circuits14:42
*** Jonathan_e has joined #circuits14:45
*** Jonathan_e has quit IRC14:45
*** RNeville has quit IRC14:46
*** techdragon has quit IRC14:56
*** techdragon has joined #circuits14:57
Romsterhi rogeriobastos prologic is asleep atm should be back in ~7 hours15:28
rogeriobastos@Romster ?15:55
rogeriobastosRomster ?15:55
rogeriobastosI have a component that listen to messages from a redis server16:06
rogeriobastosI want to run it in a poll16:07
rogeriobastosor should I use workers ?16:50
prologicrogeriobastos: Do you have access to the underlying Redis fd/socket?21:01
prologicrogeriobastos: Look at circuits/core/timers.py for an example of how to write a custom poller21:02
rogeriobastosprologic: ok, I'll take a look21:02
rogeriobastosthanks21:02
prologicno problems :)21:05
prologicif you *do* write an async redis component for circuits21:05
prologicwe'd love to have that in circuits or circuits.contrib21:06
rogeriobastosI'm using python-redis21:11
prologicyeah okay21:12
prologicso you can just use it dierctly21:13
prologicand suffer the few ms per call it takes21:13
prologicand scale horizontally21:13
prologicbut as I said if you find a nice elegant way to integrate redis and circuits via components and events21:13
prologicthat would be awesome :)21:13
prologicotherwise just calling the redis api functions directly is fine21:14
prologicI've done so in a few apps21:14
rogeriobastossorry about my (next) stupid question, but anyway21:15
rogeriobastoswhat's the best way of make/use a loop in circuits?21:16
*** Osso has quit IRC21:16
rogeriobastoswrite a custom poller or use workers directy ?21:16
rogeriobastosI need listen for new msgs in a pubsub channel on redis21:17
rogeriobastosand fire events when msgs arrive21:17
rogeriobastospython-redis offer a sync approach => for message in p.listen()21:18
rogeriobastosand a async approach => p.get_message() # that return None if there is nothing21:19
rogeriobastosprologic, any idea ?21:20
prologicyeah21:23
prologicso use the async approach21:23
prologicand write a custom poller21:23
prologicuse circuits/core/timers.py as an example21:23
prologicI gotta leave for work21:23
prologicI'll continue this conversation from there in an hour or so21:23
*** Osso has joined #circuits21:24
*** Osso has quit IRC21:33
rogeriobastosprologic: I still here22:26
rogeriobastosI write a script to test: https://gist.github.com/anonymous/a0796eed5d29cdadac8b22:55
rogeriobastosand I get this output: https://gist.github.com/anonymous/4bc4eabe4ed455a7f25a22:56
prologicman23:07
prologicfinally at work23:07
prologiclousy traffic23:07
prologicrogeriobastos: looks great23:08
prologiclook at the reduce_time_left() method on GenerateEvents23:08
prologicsee how it's use in other pollers23:08
rogeriobastosbut it doesn't work23:09
prologicbasically I think what you want to do is reduce the time left to 0 when you have an event form redis23:09
prologicso it gets processed straight away23:09
prologicit should work by the looks of your code23:11
prologicadd in the Debugger23:11
prologicand see what's going on23:11
*** ninkotech has quit IRC23:16
rogeriobastosprologic: reduce_time_left() don't fix the problem23:24
rogeriobastosI don't understand why msg event is fired after stopped event23:24
prologicyeah I know why I think23:26
prologicyou have no other pollers in the system23:27
prologicif there is no event from redis23:27
prologicyou need to call23:27
prologicevent.reduce_time_left(x)23:27
prologicwhere x is some value23:27
prologicsay 10?23:27
prologicI think it's in ms23:27
prologichave a look at how the timer works again23:27
prologicit's basically the way we handle idle in circuits23:27
prologicit will sleep forever unless told otherwise23:28
prologicby a poller and reduce_time_left() on the special generate_events object23:28
prologicotherwise your app will eat CPU needlessly23:28
prologicsorry if that wasn't clear before :)23:28
prologicthese are some of the internal machinery in circuits23:28
*** ninkotech has joined #circuits23:30
rogeriobastosprologic: you are right23:30
rogeriobastosthat fix the problem23:30
rogeriobastosthanks23:30
rogeriobastosI have one more question23:32
rogeriobastosThis poller is using the main thread23:32
rogeriobastosHow do I make this in another thread with a worker?23:33
rogeriobastosDoes this improve performance ?23:33

Generated by irclog2html.py 2.11.0 by Marius Gedminas - find it at mg.pov.lt!