Thursday, June 21, 2012

Broken pipe error in Flask server

I am using Flask for some of my internal services. If you haven't used Flask, I would absolutely recommend that you check it out.

Recently I got the following error while I was attempting to serve a page from template. In an attempt to troubleshoot the error, I wasted almost half an hour.

127.0.0.1 - - [19/Jun/2012 17:48:37] "POST /" 500 -
----------------------------------------
Exception happened during processing of request from ('127.0.0.1', 55176)
Traceback (most recent call last):
  File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
    self.process_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
    self.finish_request(request, client_address)
  File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
    self.RequestHandlerClass(request, client_address, self)
  File "/usr/lib/python2.7/SocketServer.py", line 641, in __init__
    self.finish()
  File "/usr/lib/python2.7/SocketServer.py", line 694, in finish
    self.wfile.flush()
  File "/usr/lib/python2.7/socket.py", line 303, in flush
    self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
----------------------------------------


If you happen to receive this error, most likely cause is that the template you are attempting to render using "render_template" function is not found under PROJ_ROOT/templates directory. All the templates should be present under the PROJ_ROOT/templates directory. Unfortunately you don't see an accurate error message indicating that the template is missing!

Monday, June 11, 2012

Installing Emacs 24.1

I was excited to see the announcement that Emacs 24.1 has been released.  I wanted to install and try. There were a few glitches that I faced during the installation. I thought it might be useful for someone who might be hitting the same blocks.

Once I downloaded the source code and verified the signature, I unzipped the Emacs 24.1 source code. The first "configure" run gave the following error:
configure: error: You seem to be running X, but no X development libraries
were found.  You should install the relevant development files for X
and for the toolkit you want, such as Gtk+, Lesstif or Motif.  Also make
sure you have development files for image handling, i.e.
tiff, gif, jpeg, png and xpm.
If you are sure you want Emacs compiled without X window support, pass
  --without-x
to configure.
To address this error I had to do the following:
sudo apt-get install libgtk2.0-dev libtiff4-dev libgif-dev libjpeg62-dev libpng12-dev libxpm-dev 
Then when I attempted to run configure again, I got the following error:
configure: error: The required function `tputs' was not found in any library.
These libraries were tried: libncurses, libterminfo, libtermcap, libcurses.
Please try installing whichever of these libraries is most appropriate
for your system, together with its header files.
For example, a libncurses-dev(el) or similar package.
To resolve this error I had to do the following:
sudo apt-get install libncurses-dev
Thats it. The installation was smooth. Here is the summary of commands you need to run:
sudo apt-get install libgtk2.0-dev libtiff4-dev libgif-dev libjpeg62-dev libpng12-dev libxpm-dev libncurses-dev
# You can skip this step if you don't want to verify the signature.
gpg --verify emacs-24.1.tar.bz2.sig emacs-24.1.tar.bz2
tar xvfj emacs-24.1.tar.bz2
cd emacs-24.1
./configure
make
sudo make install