Posts

Showing posts from April, 2015

In Perl keys get defined if they are accessed as hash, without checking for their existence

In the following code snippet, 'c' is not as key in 'foo' but is set to {} when the last check for foo->c->0 is called. / tmp ( ) $ cat foo . pl use strict ; use warnings ; use Data : : Dumper ; sub abcde { my $foo = { 'a' = > 1 , 'b' = > 2 } ; print Dumper ( $foo ) ; if ( exists $foo - > { c } & & defined $foo - > { c } - > { 0 } ) { print "C is defined" ; } print Dumper ( $foo ) ; if ( defined $foo - > { c } and defined $foo - > { c } - > { 0 } ) { print "C is defined" ; } print Dumper ( $foo ) ; if ( defined $foo - > { c } - > { 0 } ) { print "C is defined" ; } print Dumper ( $foo ) ; } abcde ( ) ; / tmp ( ) $ perl foo . pl $VAR1 = { 'a' = > 1 , 'b' = > 2 } ; $VAR1 = { 'a' = > 1 , 

eventlet.GreenPool.waitall() just logs the exception but doesn't raise them

waitall() method in eventlet.GreenPool doesn't raise exceptions but just logs them, whereas in case of wait on the greenthread returned by spawn from evenlet.GreenPool raises the exception. # cat foo . py import eventlet pool = eventlet . GreenPool ( 1 ) def foo ( ) : raise ValueError gt = pool . spawn ( foo ) try: pool . waitall ( ) except Exception , e : print " pool.waitall Exception raised: %r " % e try: gt . wait ( ) except Exception , e : print " gt.wait() Exception raised: %r " % e # python foo . py Traceback ( most recent call last ) : File " /usr/lib/python2.7/site-packages/eventlet/hubs/hub.py " , line 346 , in fire_timers timer ( ) File " /usr/lib/python2.7/site-packages/eventlet/hubs/timer.py " , line 56 , in __call__ cb ( * args , * * kw ) File " /usr/lib/python2.7/site-packages/eventlet/greenthread.py " , line 194 , in main result = functi