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遇到問題還會持續更新。。。

相關文章
相關標籤/搜索