Dump stacktraces of all active Threads

As jitter points out in an earlier answer sys._current_frames() gives you what you need for v2.5+. For the lazy the following code snippet worked for me and may help you: print >> sys.stderr, “\n*** STACKTRACE – START ***\n” code = [] for threadId, stack in sys._current_frames().items(): code.append(“\n# ThreadID: %s” % threadId) for filename, lineno, name, … Read more

How to create zebra-stripe CSS with TAL?

The Zope Page Templates implementation for the repeat variable has an under-documented extra parameter, parity, than gives you the string ‘odd’ or ‘even’, alternating between iterations: <table> <tr tal:repeat=”row rows” tal:attributes=”class repeat/row/parity”> <td tal:repeat=”col row” tal:content=”col”>column text text</td> </tr> </table> This is also much easier to interpolate into a string expression: tal:attributes=”class string:striped ${row/class} ${repeat/row/parity}” … Read more

Sql Alchemy QueuePool limit overflow

You can manage pool size by adding parameters pool_size and max_overflow in function create_engine engine = create_engine(“mysql://” + loadConfigVar(“user”) + “:” + loadConfigVar(“password”) + “@” + loadConfigVar(“host”) + “https://stackoverflow.com/” + loadConfigVar(“schema”), pool_size=20, max_overflow=0) Reference is here You don’t need to close the session, but the connection should be closed after your transaction has been done. … Read more

PIL “IOError: image file truncated” with big images

I’m a little late to reply here, but I ran into a similar problem and I wanted to share my solution. First, here’s a pretty typical stack trace for this problem: Traceback (most recent call last): … File …, line 2064, in … im.thumbnail(DEFAULT_THUMBNAIL_SIZE, Image.ANTIALIAS) File “/Library/Python/2.7/site-packages/PIL/Image.py”, line 1572, in thumbnail self.load() File “/Library/Python/2.7/site-packages/PIL/ImageFile.py”, line … Read more

tech