python2.7 下 的pyhook不间断卡住问题
时间: 2018-09-28来源:开源中国
前景提要
HDC调试需求开发(15万预算),能者速来!>>>
直接上代码:
环境:windowXP、7、10
问题现象:Pyhook启动后,如果静置一段时间后,大约5分钟以上,Hook出现卡住现象,过好一会才有反应,如果不间断有按键输入的话,出现卡住的概率就很低。
详情:
tornado、python2.7 pyhook、 做了一个本地Python版的收银系统,利用 concurrent . futures . ProcessPoolExecutor
启动了若干个进程,其中一个进程为单独跑pyhook,工作的内容主要有:
1、监听快捷键唤醒
2、监听并过滤扫码枪扫描到的SKU条码,及客户付款码,进而通过消息队列将支付指令送往另外一个进程进行tessreact识别金额发起支付。
问题就是:放一会,TNND的hook就好似被休眠了一样,没反应了,过好一会才有反应。
键盘回调函数里,没有夹杂任何耗时操作,及其他IO操作(目前已经发现它会导致Hook直接卡死)。
哪位大神帮忙分析分析!
部分代码如下:
tornado 主函数: with concurrent . futures . ProcessPoolExecutor ( max_workers = max_workers ) as executor : ''' 启动键盘监听 ''' executor . submit ( run_listen ) ''' 启动主程序 ''' executor . submit ( run_main ) ''' 启动定时任务 ''' executor . submit ( run_schedule ) if str ( util . get_conf ( 'keyboard' , 'ocr' ))== '1' or str ( util . get_conf ( 'keyboard' , 'ocr_manual' ))== '1' : ''' 启动 OCR''' executor . submit ( run_ocr ) if str ( util . get_conf ( 'keyboard' , 'ocr' )) == '1' : ''' 启动悬浮框 ''' executor . submit ( run_titleWins )
run_listen()函数内容: def main (): print ( 'KeyBoard Listen Start.' ) hm = pyHook . HookManager () hm . KeyDown = onKeyboardEvent hm . HookKeyboard () pythoncom . PumpMessages ()

科技资讯:

科技学院:

科技百科:

科技书籍:

网站大全:

软件大全:

热门排行