Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Locked thread
Johnny Cache Hit
Oct 17, 2011

Jaur posted:

Is it something wrong with IDLE, my drivers, my code?

It's IDLE. It doesn't play well with pygame if you don't call pygame.quit() at the end.

See the pygame wiki entry for more (and ignore the spam).

Adbot
ADBOT LOVES YOU

Hanpan
Dec 5, 2004

Haystack posted:

Check out Supervisor for a pre-rolled solution.

Looks great. Thanks!

fritz
Jul 26, 2003

GregNorc posted:

Let's say I have a list of five integers. For sake of simplicity, l = [1,2,3,4,5]

I want to calculate all the possible ways they could be combined.

Due to my time constraints I'm attempting a simple brute force solution: generate all the possible combinations. Sum all the possible combinations. Spit out all the combinations whose total are less than a certain threshold.

If anyone can help, I'd greatly appreciate it.


This is too late but I would have iterated from 0 to 31 (inclusive), grabbed the binary representation of each integer, and used that to pick elements from the list.

Scaevolus
Apr 16, 2007

I just discovered that this is valid in Python 3:

code:
def f(x:int, y:float):
    print(x, y)
Because the grammar reads:
code:
parameters: '(' [typedargslist] ')'
typedargslist: (tfpdef ['=' test] (',' tfpdef ['=' test])* [','
      ['*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef]]
    |  '*' [tfpdef] (',' tfpdef ['=' test])* [',' '**' tfpdef] | '**' tfpdef)
tfpdef: NAME [':' test]
"test" is the topmost rule for expressions.

But the only information I can find about it is the diff that introduced it.

Apparently the test expressions are evaluated when the function is defined:
code:
>>> def f(x:print("x"), y:print("y")): pass
... 
x
y
>>> f(1,2)
>>>
Does anyone know what's going on?

Scaevolus fucked around with this message at 18:58 on Oct 20, 2011

Yay
Aug 4, 2007

Scaevolus posted:

I just discovered that this is valid in Python 3:

code:
def f(x:int, y:float):
    print(x, y)
But the only information I can find about it is the diff that introduced it.

Does anyone know what's going on?

Those look like the type annotations in PEP 3107. As far as I know, the standard lib & interpreter do nothing with them, but you could build tools around that extra data.

'ST
Jul 24, 2003

"The world has nothing to fear from military ambition in our Government."
More explicitly,

code:
>>> def func(x:int, y:float):
...    print(x, y)
...
>>> print(func.__annotations__)
{'y': <class 'float'>, 'x': <class 'int'>}

Lurchington
Jan 2, 2003

Forums Dragoon
the likely use case for annotations (and for them being arbitrary functions) would be for your unittests to make assertions that it's bringing and returning expected types.

code:
def f(x:int, y:str) -> float:
    return 1.1
without keeling over and dying if production turns out to give you something else

edit: I guess IDEs could make use of it as well

Lurchington fucked around with this message at 19:17 on Oct 21, 2011

maskenfreiheit
Dec 30, 2004
Edit: doublepost

maskenfreiheit fucked around with this message at 01:24 on Mar 13, 2017

taqueso
Mar 8, 2004


:911:
:wookie: :thermidor: :wookie:
:dehumanize:

:pirate::hf::tinfoil:

How about [0] * 10?

e:
code:
>>> print [0] * 10
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
>>> 

maskenfreiheit
Dec 30, 2004
Edit: doublepost

maskenfreiheit fucked around with this message at 01:24 on Mar 13, 2017

tripwire
Nov 19, 2004

        ghost flow

GregNorc posted:

If I nest it, then it seems to only create one list, and reference everything else."

Example:

code:
>>> x = [[0] * 10]*10
>>> x[0][1] += 1
>>> i = 0
>>> while i < 10:
...     print x[i]
...     i += 1
... 
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
[0, 1, 0, 0, 0, 0, 0, 0, 0, 0]
I need it so if x[0][1] = 1, x[1][1] would still stay zero (as would the rest of the matrix)

That's a caveat of the [ expr ] * 5 syntax: expr is evaluated once and referenced in the other list entries:

code:
>> class Foo(object):pass
...
>>> a = [Foo()] * 5
>>> id(a[0]) == id(a[1])
True
You want list comprehensions:
code:
>>> x = [ range(10) for _ in xrange(10) ]
>>> x[0][1] += 1
>>> while i < 10:
...     print x[i]
...     i += 1
...
[0, 2, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
The syntax for list comprehensions is like this:
[ expr for captured variable name in sequence ]
expr can be any valid python expression, although typically you would use the captured variable in the expression somewhere.
In the example above though, I don't use the captured variable, so I stick with the convention of naming it _ (to indicate a dummy/meaningless variable).

tripwire fucked around with this message at 23:34 on Oct 21, 2011

maskenfreiheit
Dec 30, 2004
Edit: doublepost

maskenfreiheit fucked around with this message at 01:25 on Mar 13, 2017

tripwire
Nov 19, 2004

        ghost flow

GregNorc posted:

Ok... I think I understand...

Can you show me one where it generates all zeros? All the syntax is sort of blending together, I'm having trouble seeing what's causing what to happen.

The expr part above can be any valid python expression.. including just 0, or another list comprehension!

Check this out:
code:
>>> def nested_list_matrix(width,height, initial_value = 0 ):
...     return [ [ initial_value for _ in xrange(width) ] for _ in xrange(height) ] 
...
>>> for row in nested_list_matrix(6,4):
...     for value in row:
...         print value,
...     print
...
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0
0 0 0 0 0 0

TasteMyHouse
Dec 21, 2006

tripwire posted:


code:
>>> x = [ range(10) for _ in xrange(10) ]
>>> x[0][1] += 1
>>> while i < 10:
...     print x[i]
...     i += 1
...
[0, 2, 2, 3, 4, 5, 6, 7, 8, 9]  # <--- why is this [0,2,2,...]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]

BeefofAges
Jun 5, 2004

Cry 'Havoc!', and let slip the cows of war.

TasteMyHouse posted:



x[0][1] += 1

TasteMyHouse
Dec 21, 2006
e: Hey I should read threads

TasteMyHouse fucked around with this message at 00:26 on Oct 22, 2011

tef
May 30, 2004

-> some l-system crap ->

GregNorc posted:

Ok... I think I understand...

Can you show me one where it generates all zeros? All the syntax is sort of blending together, I'm having trouble seeing what's causing what to happen.

you could just do

code:
row = []
for _ in range(10):
    row.append(0)

matrix = []
for _ in range(10):
    matrix.append(list(row)) # make a copy of row
:shobon:

Yay
Aug 4, 2007
Or you could do
code:
list_count = 10
sub_list_length = 5
result = [[0]*sub_list_length for x in range(list_count)]
Optionally converting it to a generator object. I've split it up so that its readable if you're not familiar with list comprehensions, because lord knows they seemed odd to me, in the beginning.

Or, if you really need performance, I think numpy has explicit functions for ones() and zeroes() which do the same job.

fnordcircle
Jul 7, 2004

PTUI
Still learning python.

I'm working on a new project for converting Checkpoint firewall rulebases. I want to read the values from the rules and objects text files and store them in a data structure that looks like this in my head:

code:
Rule 1

Sources:
Net_10
Net_172

Destinations:
ServerA
ServerB
ServerC
ServerD

Ports:
80
443
For every rule in the rulebase. The issue is that Rule 1 might have 1 source, 1 destination and 1 port, whereas rule 75 might have 10 sources, 16 destinations and 53 ports. Basically the number of policy elements under the Source, Destination and Port sections above varies from rule to rule.

Is there a built-in data structure similar to dictionaries that would work for this? I've been reading a lot and I'm probably just not knowing the right stuff to google for to find it.

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

fnordcircle posted:

Still learning python.

I'm working on a new project for converting Checkpoint firewall rulebases. I want to read the values from the rules and objects text files and store them in a data structure that looks like this in my head:

code:
Rule 1

Sources:
Net_10
Net_172

Destinations:
ServerA
ServerB
ServerC
ServerD

Ports:
80
443
For every rule in the rulebase. The issue is that Rule 1 might have 1 source, 1 destination and 1 port, whereas rule 75 might have 10 sources, 16 destinations and 53 ports. Basically the number of policy elements under the Source, Destination and Port sections above varies from rule to rule.

Is there a built-in data structure similar to dictionaries that would work for this? I've been reading a lot and I'm probably just not knowing the right stuff to google for to find it.

Unless I'm misunderstanding, I think you could just create a class with the sources, destinations, and ports as lists assigned to attributes or returned via methods.

Something like: (not tested and just typed up here without much thought)
code:
class Rules():
    def __init__(self, sources, destinations, ports):
        self.sources = sources
        self.destinations = destinations
        self.ports = ports

sources = ["Net_10", "Net_172"]
destinations = ["ServerA", "ServerB", "ServerC", "ServerD"]
ports = [80, 443]

Rule1 = Rules(sources, destinations, ports)
There's lots of things you can do here...this is about the most barebones implementation of an object you can get.

Thermopyle fucked around with this message at 18:57 on Oct 24, 2011

fnordcircle
Jul 7, 2004

PTUI
Ok cool I'll read more about classes. I've sort of been taking the 'learn about what I need to learn right now' approach since I'm typically working on tight deadlines.

Thanks man!

duck monster
Dec 15, 2004

fnordcircle posted:

Ok cool I'll read more about classes. I've sort of been taking the 'learn about what I need to learn right now' approach since I'm typically working on tight deadlines.

Thanks man!

Remember, when you do OO, model the problem abstractly: Entities have states(variables) and messages ("Do this, little objects") aka methods, then implement them. Its amazingly powerful as long as you think of it this way.

fnordcircle
Jul 7, 2004

PTUI

duck monster posted:

Remember, when you do OO, model the problem abstractly: Entities have states(variables) and messages ("Do this, little objects") aka methods, then implement them. Its amazingly powerful as long as you think of it this way.

I think I have a little ways to go to wrap my head around it all.

Got one question, which I imagine will highlight how I'm not 'getting' classes yet.

If I have a variable named netobj, how do I create a class instance whose name is the value of that variable?

So if netobj = 'Block_Group', how can I use that to create a class named Block_Group?

fart simpson
Jul 2, 2005

DEATH TO AMERICA
:xickos:

So I'm using gevent for the first time today and there's something I want to do but I'm dumb and can't figure it out even though it's probably trivial. Right now I just have a little script that spawns a number of greenlets that then sleep for a random amount of time. What I want to do is keep track of how many are still alive and how many are done. Like, kinda a progress bar thing.

Here's a trivial example. How could I find out what percentage of them have completed at any given time?

code:
import gevent
from gevent import Greenlet
import random

class G(Greenlet):  
    def __init__(self, seconds, i):
        Greenlet.__init__(self)
        self.seconds = seconds
        self.i = i
    def _run(self):
        gevent.sleep(self.seconds)
        print 'im {}'.format(self.i)

jobs = [G.spawn(random.randint(1,5), i) for i in range(10)]
gevent.joinall(jobs)

FoiledAgain
May 6, 2007

fnordcircle posted:

I think I have a little ways to go to wrap my head around it all.

Got one question, which I imagine will highlight how I'm not 'getting' classes yet.

If I have a variable named netobj, how do I create a class instance whose name is the value of that variable?

So if netobj = 'Block_Group', how can I use that to create a class named Block_Group?

Is this what you're asking about?

code:
class Thingy(object):

    def __init__(self,name):
        self.name = name

netobjname = 'Block_Group'
netobj = Thingy(netobjname)
print netobj.name
This would print out 'Block_Group'.

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe

pliable posted:

I have no idea where to ask this, so I have chosen YOU, Game Development Megathread!

Are there any pygame/Python experts out there? I'm trying to get this Python version of Pac-Man running on my machine (http://pinproject.com/pacman/pacman.htm) and it seems to be impossible. I'm running OSX v. 10.7.1. I followed the tutorial to set it up on Lion. I installed the SDL frameworks. I installed a shitload of other libraries...yet it still refuses to launch. Any help would be greatly appreciated, thanks!

Reposting this here to hopefully get more answers...

Vogler
Feb 6, 2009
I'm looking for a tutor who can teach me to solve basic mathematical assignments in Python (polynomials, differential equations, etc.)

Your job would just be to answer sporadic questions on Skype to keep everything running smoothly. 12 bucks an hour. If you are interested, send a mail to fredrikvogler at gmail.

fnordcircle
Jul 7, 2004

PTUI

FoiledAgain posted:

Is this what you're asking about?

Thanks! But I don't think I'm doing a good job explaining what I'm asking.

I have a file with hundreds of network objects from a checkpoint firewall. They are in blocks like this:
code:
		: (net-192.168.103.96_27
			:add_adtr_rule (false)
			:broadcast (allow)
			:ipaddr (192.168.103.96)
			:location (internal)
			:netmask (255.255.255.224)
			:type (network)
			:IPSec_main_if_nat (false)
		)
		: (SA-ED
			:group_sort_type (3)
			:is_convention_on (false)
			:member_class (network_object)
			:type (group)
			: SA-internal
			: net-192.168.103.96_27
			:IPSec_main_if_nat (false)
		)
The first object name is net-192.168.103.96_27. The second object name is SA-ED.

Depending on the object type (network or group in this instance) I need to extract the name, IP, netmask and any group members (the two lines after :type (group) )and assign them to attributes of a class instance.

Basically I need to build out a long data structure to store all of these values for each of these checkpoint network objects which I can then extract the data from later when I'm parsing the actual rulebase which references these checkpoint data values.

I guess what I'm confused about is what the best way to do this is and how to do it on the fly. If I'm understanding correctly your code above just creates a class instance named netobj.

I can manually create a new class instance, like you do with netobj above, but I need to do this dynamically for hundreds of checkpoint network objects.

Captain Capacitor
Jan 21, 2008

The code you say?

pliable posted:

Reposting this here to hopefully get more answers...

You might have to give us a little more than that. Are you running it from the command line? Is there any output at all? Are you using the stock version of Python that comes with OSX?

fnordcircle posted:

Thanks! But I don't think I'm doing a good job explaining what I'm asking.

I have a file with hundreds of network objects from a checkpoint firewall. They are in blocks like this:

If you were more comfortable with Python (not a dig at you, everyone starts somewhere) I'd suggest PyParsing or something similar.

fnordcircle
Jul 7, 2004

PTUI

Captain Capacitor posted:

If you were more comfortable with Python (not a dig at you, everyone starts somewhere) I'd suggest PyParsing or something similar.

Nah, not at all. At this point I've ditched the idea of objects for now since I clearly don't get it and I've got to get this done by the end of the day.

For now I'm just going with a list with a line for each object appending all the data I need to that one line and starting the line with the checkpoint object name so I can fiddle with them later.

Thanks!

pliable
Sep 26, 2003

this is what u get for "180 x 180 avatars"

this is what u fucking get u bithc
Fun Shoe

Captain Capacitor posted:

You might have to give us a little more than that. Are you running it from the command line? Is there any output at all? Are you using the stock version of Python that comes with OSX?

Yeah, sorry about that...

Yes, attempting to run it from the command line, and I tried using both python and pythonw. This is the output I get with either:

code:
18:03[pliable@Steves-MacBook-Pro]~/Dropbox/School/CSC480/trunk$ python pacman.pyw
Traceback (most recent call last):
  File "pacman.pyw", line 44, in <module>
    img_Background = pygame.image.load(os.path.join(SCRIPT_PATH,"res","backgrounds","1.gif"))
pygame.error
I'm not using the stock version that came with OS X. I'm using the one from python.org (specifically, http://www.python.org/ftp/python/2.7.2/python-2.7.2-macosx10.6.dmg). I think the stock one is located in /usr/bin/python, right? If so, I've tried using that one as well with no success :(.

Eggnogium
Jun 1, 2010

Never give an inch! Hnnnghhhhhh!

fnordcircle posted:

Nah, not at all. At this point I've ditched the idea of objects for now since I clearly don't get it and I've got to get this done by the end of the day.

For now I'm just going with a list with a line for each object appending all the data I need to that one line and starting the line with the checkpoint object name so I can fiddle with them later.

Thanks!

Classes and objects are are possibly the most powerful paradigm in modern programming so don't dismiss them as some fringe feature. Unfortunately, in my opinion at least, classes are where the "Python is easy for beginners" mantra breaks down. For learning object oriented programming, a purely OO language like Java or C# tends to be much simpler. Objects and classes lose some of their purity when they're hedged into scripting languages like Python and Javascript, which is fine for experienced developers but not helpful when you're a new programmer trying to "get" classes and objects and inheritence.

tef
May 30, 2004

-> some l-system crap ->

Eggnogium posted:

Classes and objects are are possibly the most powerful paradigm in modern programming so don't dismiss them as some fringe feature. Unfortunately, in my opinion at least, classes are where the "Python is easy for beginners" mantra breaks down. For learning object oriented programming, a purely OO language like Java or C# tends to be much simpler. Objects and classes lose some of their purity when they're hedged into scripting languages like Python and Javascript, which is fine for experienced developers but not helpful when you're a new programmer trying to "get" classes and objects and inheritence.

Not that we're in the wrong thread to discuss this (we are), but you may enjoy picking a fight over in this thread here: http://forums.somethingawful.com/showthread.php?threadid=3444008

For what it is worth I think teaching object orientation first causes brain damage.

fnordcircle
Jul 7, 2004

PTUI

Eggnogium posted:

Classes and objects are are possibly the most powerful paradigm in modern programming so don't dismiss them as some fringe feature. Unfortunately, in my opinion at least, classes are where the "Python is easy for beginners" mantra breaks down. For learning object oriented programming, a purely OO language like Java or C# tends to be much simpler. Objects and classes lose some of their purity when they're hedged into scripting languages like Python and Javascript, which is fine for experienced developers but not helpful when you're a new programmer trying to "get" classes and objects and inheritence.

Oh no, definitely not. Basically we have a hundred conversions we have to do and everyone has been doing them by hand. Converting a Proventia-M firewall or Checkpoint to an ASA takes 2-4 days of an engineer's time. I have a hard-on for automation, which I typically accomplish with Autohotkey.

So I get scheduled 4 days to do a firewall build and I've been 'stealing' a day or two of that time to build a python conversion script. So while I'd love to sit and learn classes the pressure of the clock ticking is kinda stressful so I have to go with what I know. Even if it means I'll spend 2 hours doing something I could probably do in 15 minutes if I understood the language better but it doesn't seem like I'll be able to learn something like classes in 2 hours.

In the end I realized that just using dictionaries with specifically-formated data strings was much easier for me to accomplish now, but I thoroughly intend to get a better grasp of classes since I'd love to end up writing my own python roguelike-ish program sometime down the road.

Thanks for the encouragment to look into classes!

Senso
Nov 4, 2005

Always working
I'd like some input on this project I'm working on.
Short blurb: A daemon receives emails from Postfix and decides if they should be sent from the server or piped through Amazon's SES service.

Postfix pipes the email to a small client that uses a ZeroMQ (0MQ) queue to talk to the daemon. The daemon keeps stats, like how many emails sent locally, how many through SES, how many bounces received, etc.
I would like to be able to query the stats at any time, so I also added a simple socket server that listens on a TCP port and outputs the stats to any connection.

Now, since I'm already polling the ZMQ queue in a while True loop, I need to have another such loop for my TCP socket. My initial thought was to spawn a separate process for the stats TCP socket. That works well but passing objects between the main ZMQ loop process and the TCP loop process is annoying. Right now, I use multiprocessing.Manager to have a shared list between the two procs but it's not working with dictionaries and it gets even more annoying if I have to copy/modify lists between the two.

So I started looking at having everything in the same process but to use nonblocking/zmq.NOBLOCK modes, a bit like this:
code:
while True:
	while True:
		try:
			proc.socket.recv(zmq.NOBLOCK)
		except:
			break
		# Here I do stuff to the ZMQ queue
		
	while True:
		try:
			conn, addr = stats.socket.accept() # this is set to nonblocking elsewhere
			derp = conn.recv(1024)
			conn.close()
		except:
			break
		# Here I do stuff to the TCP socket connection
But that looks ugly, I don't like looping over non-blocking sockets and generating thousands of exceptions per second (CPU obviously goes to 100% if I don't put a time.sleep() call in that loop).

So maybe I'm just missing another way of doing this. I don't want to post the stats to a webapp or store them in a DB, I'd like a low-key way of telling the daemon, "Hey, where are you at?" If i use multiprocessing.Pipe[ between the two processes, each process would need to have a second loop on that pipe and that starts looking messy.

Anybody got suggestions or ideas?

tef
May 30, 2004

-> some l-system crap ->
have you thought about using threads?

Senso
Nov 4, 2005

Always working

tef posted:

have you thought about using threads?

I never really used threads before, with the reputation of being more complex and hard to debug. I'll give threads a look tomorrow. Is sharing objects between threads much easier than with multiprocessing?

Captain Capacitor
Jan 21, 2008

The code you say?
Have you thought of using ZeroMQ's polling facilities? You can add multiple sockets to it and poll for any activity on them.

Captain Capacitor fucked around with this message at 16:50 on Nov 1, 2011

Senso
Nov 4, 2005

Always working

Captain Capacitor posted:

Have you thought of using ZeroMQ's polling facilities? You can add multiple sockets to it and poll for any activity on them.

Yeah I did look at that, but ZeroMQ TCP sockets don't support telnet (or even netcat) so I'd need to write a small client that uses ZeroMQ's REQ/REP. Ideally, I'd like to avoid creating a specific client just to pool the stats, to eventually plug it into Nagios or Cacti, or just to allow non-python colleagues to quickly get stats.

I found some kind of hack that mixes asyncore and zmq, haven't tried it yet but I'm not sure it even works.

Adbot
ADBOT LOVES YOU

Thermopyle
Jul 1, 2003

...the stupid are cocksure while the intelligent are full of doubt. —Bertrand Russell

Senso posted:

Yeah I did look at that, but ZeroMQ TCP sockets don't support telnet (or even netcat) so I'd need to write a small client that uses ZeroMQ's REQ/REP. Ideally, I'd like to avoid creating a specific client just to pool the stats, to eventually plug it into Nagios or Cacti, or just to allow non-python colleagues to quickly get stats.

I found some kind of hack that mixes asyncore and zmq, haven't tried it yet but I'm not sure it even works.

I don't have time at the moment to think about your problem in detail, but I've done similar sorts of things with eventlet.

  • Locked thread