python pdb 简单使用

启动pdb:

python -m pdb

定义断点:

b lineno
b filename:lineno

查看断点列表: b

删除断点:
cl 断点编号

运行程序: r

c : 断点运行

查看变量的值:
print 变量名

查看代码: l

n 下一步
s 下一步 会进入到函数内部

bt 函数调用栈

一段多线程死锁代码

data = []
lock = thread.allocate()

def getItem():
  item = None
  if lock.acquire():
    if 0 != len(data) :
      item = data.pop()
      lock.release()
  return item

以上代码显示,只有当任务队列里有数据的时候才会释放锁,否则,不释放,将引发其他相关的消费线程锁死。

vim 文件备份

set nu
syntax on
set tabstop=4

set hlsearch   
set incsearch " increment search
set showmatch " when keyup the right ) the left ( bright
set background=dark

set nocompatible
filetype on
filetype off
set rtp+=~/.vim/bundle/vundle
let path='~/.vim/bundleplugins'
call vundle#rc(path)

Plugin 'gmarik/vundle'
Plugin 'Emmet.vim'
Plugin 'AutoComplPop'
Plugin 'scrooloose/nerdtree' 
Plugin 'php.vim-html-enhanced' 
Plugin 'bling/vim-airline'
Plugin 'fugitive.vim'
Plugin 'elzr/vim-json'
Plugin 'matchit.zip'
Plugin 'godlygeek/tabular'
Plugin 'plasticboy/vim-markdown'

call vundle#end()

filetype plugin indent on  

set laststatus=2

map <C-n> :NERDTreeToggle<CR>

au FileType php call PHPFuncList()
function PHPFuncList()
				set dictionary-=~/.vim/dict/php_funclist
				set dictionary+=~/.vim/dict/php_funclist
				set complete-=k complete+=k
endfunction

colorscheme solarized
"colorscheme blue
""colorscheme darkblue
""colorscheme default
""colorscheme delek
""colorscheme desert
"colorscheme elflord
""colorscheme evening
"colorscheme koehler
""colorscheme morning
""colorscheme murphy
"colorscheme pablo
""colorscheme peachpuff
"colorscheme ron
""colorscheme shine
"colorscheme slate
"colorscheme torte
""colorscheme zellner

"保存时检测php文件的语法
autocmd BufWritePost *.php call PHPSyntaxCheck()

if !exists('g:PHP_SYNTAX_CHECK_BIN')
    let g:PHP_SYNTAX_CHECK_BIN = 'php'
endif

function! PHPSyntaxCheck()
    let result = system(g:PHP_SYNTAX_CHECK_BIN.' -l -n '.expand('%'))
    if (stridx(result, 'No syntax errors detected') == -1)
        echohl WarningMsg | echo result | echohl None
    endif
endfunction

set modifiable

autocmd StdinReadPre * let s:std_in=1
autocmd VimEnter * if argc() == 0 && !exists("s:std_in") | NERDTree | endif