thrift的使用及遇到的问题

centos 系统安装官方文档:http://thrift.apache.org/docs/install/centospython

1、按该文档安装出现了一系列的问题,记录以下:git

1.安装thrift时./bootstrap.sh出错,而后安装libevent问题解决
(首先:git gc,清除./configure 和make错误的信息)
# wget http://www.monkey.org/~provos/libevent-1.2.tar.gz

# tar zxvf libevent-1.2.tar.gz
# cd libevent-1.2
# ./configure –prefix=/usr
# make
# make install

2.安装thrift到make步骤时出现以下错误:apache

  g++: error: /usr/lib64/libboost_unit_test_framework.a: No such file or directorybootstrap

3.../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evutil_make_socket_closeonexec'centos

  ../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evbuffer_get_length'app

  ../../../lib/cpp/.libs/libthriftnb.so: undefined reference to `evbuffer_pullup'框架

  collect2: error: ld returned 1 exit statussocket

4.automake --add-missing”时出错及解决办法:ui

a. configure.ac: error: no proper invocaction of AM_INIT_AUTOMAKE was found.
b. Makefile.am: error: required file './NEWS' not found
    Makefile.am: error: required file './README' not found
    Makefile.am: error: required file './AUTHORS' not found
    Makefile.am: error: required file './ChangeLog' not found
    使用命令:automake --add-missing --copy --foreign
c. required file `config.h.in' not found 
  解决:在执行automake --add-missing以前执行autoheader,生成config.h.in
d. Libtool library used but `LIBTOOL' is undefined?
  解决:重装libtool 而后再运行
  try run “libtoolize” in that directory first, and then re-run autoreconf
e. /usr/share/automake-1.14/am/depend2.am: error: am__fastdepCXX does not appear in AM_CONDITIONAL
  在configure.ac 中加入
AC_INIT
AM_INIT_AUTOMAKE

dnl add this
AC_PROG_CXX

AC_PROG_LIBTOOL

  本人安装thrift遇到了各类各样的坑,真是一波三折,差点放弃,但愿thrift能把安装过程完善一下,让使用者投入更多的时间在使用上而不是安装上。this

2、Thrift python使用过程遇到的错误:

No handlers could be found for logger "thrift.server.TServer"

参考网址:http://blog.csdn.net/mantoureganmian/article/details/48340215

  thrift框架作的很好,封装的也很好,不单单有代码生成功能,并且还有错误处理机制。这种错误处理机制处理过程是:当Handler类中的出现错误时,一概提示:“No handlers could be found for logger "thrift.server.TServer"”。换句话说,当变量拼写错误时,不会提示某个变量未命名,而提示“No handlers could be found for logger "thrift.server.TServer"”,这样无疑增长了改错难度,坑啊!!!

   对于此,比较好的解决方案是:使用try....except  Exception as e:模块来手动打印错误。try模块代码示例以下:

try:  
    a=b  
except Exception as  e:  
    print e  

  我代码出错的缘由是:server端返回给了client端字符串为汉字,改为拼音问题解决。

  thrift总体来讲仍是很好用的,特别是支持跨多种语言,减小了开发者间的通讯难度。

  本人菜鸟一枚,但不会在菜鸟的路上越走越远,thrift遇到问题还会持续更新。。。