Pythonic way for handling file errors

2007-10-10 Thread wink
;r') as f with exceptions: content = f.read() error = 200 except Exception: error = 404 Another words from looking at PEP343 it is the author of the object returned by the with expression that gets to decide if exceptions are re-raised. But it would seem to me it should be the programme

Re: Asynchronous Messaging

2007-09-27 Thread wink
plus the not_full Condition variable plus the call to _put (which is a call to the deque.append) plus a notify on the not_empty conditional, so it's not surprising it's slower. If and when I think Queue is a performance impediment to an mproc I'll take another look at it, for now

Re: Asynchronous Messaging

2007-09-26 Thread wink
Fredrik, You are most correct, but Queue is slow compared to deque but not for the reason I guessed. Apparently it's because deque is implemented in C while Queue is in python. Using the program below it looks there is about a 35:1 speed difference. 100 d.append 0.11s 0.1097us p

Re: Asynchronous Messaging

2007-09-26 Thread wink
On Sep 26, 4:47 am, wink <[EMAIL PROTECTED]> wrote: To make it easier to comment on the code, I'm including "mproc.py" file below. Fredrik, was commenting about using Queue and in fact I do. Queue is quite nice and is also thread safe, which is a requirement for this im

Asynchronous Messaging

2007-09-26 Thread wink
threads without having to contend with the associated issues mutexes have in the area of deadly embraces or race conditions. Anyway, below is a link to the first pass at an implementation in Python, comments are welcome: http://www.saville.com/python/mproc.tgz Regards, Wink Saville -- http://