V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  hanssx  ›  全部回复第 62 页 / 共 63 页
回复总数  1250
1 ... 54  55  56  57  58  59  60  61  62  63  
2019-03-14 11:45:51 +08:00
回复了 hanssx 创建的主题 Python 使用 pycharm 对 Python 项目调试遇到非常诡异的现象
最后发现好像是 py3.7 的问题,换成 py2.7 可以了。
参考: https://forums.fast.ai/t/pycharm-ide-debugger-exception/28909/4
2019-03-13 23:09:55 +08:00
回复了 hanssx 创建的主题 Python 使用 pycharm 对 Python 项目调试遇到非常诡异的现象
@chenqh 但是我发现在虚拟机中使用 pycharm 调试,在使用了进程池的附近也会报一样的 KeyboardInterrupt 错误,看来不是远程调试的问题,不过师傅已经帮我解决了一个问题,师傅请问微信或者 qq 私聊或者发我吧,我给师傅转钱,我的 qq 是 9614 六 2392
@lniwn 提前下好,下到出错的后面了,也不行呢,感谢师傅。
2019-03-13 23:03:17 +08:00
回复了 hanssx 创建的主题 Python 使用 pycharm 对 Python 项目调试遇到非常诡异的现象
@chenqh 多谢师傅回复,没想到确实是这样,stream.write(message)改成 stream.write(message.decode('utf-8'))就可以了。
2019-03-13 22:28:03 +08:00
回复了 hanssx 创建的主题 Python 使用 pycharm 对 Python 项目调试遇到非常诡异的现象
pycon 群里刘师傅说了一个问题,“你用的是虚拟环境下的 python,为啥报错目录是 /usr/local/python3 呢”
我也感觉好奇怪,按道理来说,报错应该是在虚拟环境下的吧?!
2018-11-30 14:47:14 +08:00
回复了 hanssx 创建的主题 Python logging format 如何优雅地对齐
@lolizeppelin 为何不要用制表符呢?能详细说下吗
2018-11-05 16:52:13 +08:00
回复了 hanssx 创建的主题 Python logging format 如何优雅地对齐
@chinawrj 感谢感谢,是我要的答案,嘿嘿。
@kslr 兄弟没听明白你的意思,我只在一台机器运行一个 worker,在 20 台机器运行 20 个 worker。。
@daya 首先清除 gunicorn 多余进程,使用 netstat -antlp | grep port 或者 ps -ef | grep guni,然后 sudo kill -9 pid
然后再把 gevent-websocket 换成 gevetn,因为前者不支持 py3
最后把 flask-socketio 的 async_mode 换成 eventlet 而不是 gevent,gevent 会一直发送类似心跳包的东西,不知道有没有选项可以清除。
已解决,感谢各位的帮助,特别是 itertools。
@itertools 确实,老哥,能加您个 QQ 吗?想感谢您一下,gevent+flask-socketio 就会一直发请求并且 pending,eventlet 则不会,怎么会这样我也不明白,我的扣扣 9614 六 2392,期待老哥,哈哈。
@itertools 我晕,我本地不加 gunicorn,socketio.run(app=app, host='0.0.0.0', port=5000, debug=True),指定 async_mode='gevent',也会一直 pending,一直请求。。。
@itertools 我 flask 应用程序的启动代码:socketio.run(app=app, host='0.0.0.0', port=5000, debug=True)
其中 socketio 初始化时,指定了 async_mode='gevent',是这个原因吗?然后 gunicorn 也使用了 gevent。
@itertools 是的,不支持 py3,真是我的锅,第一次部署花了很多时间,使用了 gevent 之后没有 402 错误了,但是会一直 pending,gunicorn 日志显示好像是心跳包,正在找办法关了它。。。
[2018-10-11 16:40:27 +0800] [12128] [INFO] Shutting down: Master
[2018-10-11 16:41:47 +0800] [13014] [INFO] Starting gunicorn 19.9.0
[2018-10-11 16:41:47 +0800] [13014] [INFO] Listening at: http://127.0.0.1:5000 (13014)
[2018-10-11 16:41:47 +0800] [13014] [INFO] Using worker: gevent
[2018-10-11 16:41:47 +0800] [13017] [INFO] Booting worker with pid: 13017
Server initialized for gevent.
94207eaf37114c118b05480ba12679ef: Sending packet OPEN data {'sid': '94207eaf37114c118b05480ba12679ef', 'upgrades': [], 'pingTimeout': 60000, 'pingInterval': 25000}
94207eaf37114c118b05480ba12679ef: Sending packet MESSAGE data 0
94207eaf37114c118b05480ba12679ef: Received packet MESSAGE data 0/process_upload_csv
94207eaf37114c118b05480ba12679ef: Sending packet MESSAGE data 0/process_upload_csv
94207eaf37114c118b05480ba12679ef: Received packet PING data None
94207eaf37114c118b05480ba12679ef: Sending packet PONG data None
94207eaf37114c118b05480ba12679ef: Received packet PING data None
94207eaf37114c118b05480ba12679ef: Sending packet PONG data None
94207eaf37114c118b05480ba12679ef: Received packet PING data None
清理了 gunicorn 进程,抛弃了 websocket-gevent,使用了 gevent,gunicorn -b 127.0.0.1:5000 -k gevent -w 1 module:app,不再报 402 错误了,但是程序还是会一直 pending,一直发请求。。。
开启了 flask-socketio 的日志,现在重新启动,ps -ef | grep guni 出现 2 行,其中 1 行是 work,work 数应该没错,日志现在报错,继续搜索解决方案,
[2018-10-11 15:19:04 +0800] [697] [INFO] Starting gunicorn 19.9.0
[2018-10-11 15:19:04 +0800] [697] [INFO] Listening at: http://127.0.0.1:5000 (697)
[2018-10-11 15:19:04 +0800] [697] [INFO] Using worker: geventwebsocket.gunicorn.workers.GeventWebSocketWorker
[2018-10-11 15:19:04 +0800] [700] [INFO] Booting worker with pid: 700
Server initialized for gevent.
bae5c5f54be848fcabd9e5cfe8ce59fa: Sending packet OPEN data {'sid': 'bae5c5f54be848fcabd9e5cfe8ce59fa', 'upgrades': ['websocket'], 'pingTimeout': 60000, 'pingInterval': 25000}
bae5c5f54be848fcabd9e5cfe8ce59fa: Sending packet MESSAGE data 0
bae5c5f54be848fcabd9e5cfe8ce59fa: Received packet MESSAGE data 0/process_upload_csv
bae5c5f54be848fcabd9e5cfe8ce59fa: Sending packet MESSAGE data 0/process_upload_csv
Traceback (most recent call last):
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 975, in handle_one_response
self.run_application()
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/geventwebsocket/handler.py", line 82, in run_application
self.process_result()
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 909, in process_result
self.write(data)
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 756, in write
self._write_with_headers(data)
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 777, in _write_with_headers
self._write(data)
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 741, in _write
self._sendall(data)
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 703, in _sendall
self.socket.sendall(data)
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/_socket3.py", line 457, in sendall
data_memory = _get_memory(data)
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/_socket3.py", line 45, in _get_memory
mv = memoryview(data)
TypeError: memoryview: a bytes-like object is required, not 'str'
2018-10-11T07:20:48Z {'REMOTE_ADDR': '127.0.0.1', 'REMOTE_PORT': '54310', 'HTTP_HOST': '10.26.15.222', (hidden keys: 31)} failed with TypeError

bae5c5f54be848fcabd9e5cfe8ce59fa: Client is gone, closing socket
bae5c5f54be848fcabd9e5cfe8ce59fa: Client is gone, closing socket
ca996671e95d4e54834a745c9129caa8: Sending packet OPEN data {'sid': 'ca996671e95d4e54834a745c9129caa8', 'upgrades': ['websocket'], 'pingTimeout': 60000, 'pingInterval': 25000}
ca996671e95d4e54834a745c9129caa8: Sending packet MESSAGE data 0
ca996671e95d4e54834a745c9129caa8: Received packet MESSAGE data 0/process_upload_csv
ca996671e95d4e54834a745c9129caa8: Sending packet MESSAGE data 0/process_upload_csv
Traceback (most recent call last):
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 975, in handle_one_response
self.run_application()
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/geventwebsocket/handler.py", line 82, in run_application
self.process_result()
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 909, in process_result
self.write(data)
File "/root/.local/share/virtualenvs/asset-ar0OxIPP/lib/python3.7/site-packages/gevent/pywsgi.py", line 756, in write
@itertools 打扰,我已经重新清理了之后使用 sudo kill -9,确认网站访问不了,然后重新 supervisord -c /etc/supervisord.conf
问题依然还在,日志中是这样,请问这是 work 吗?这和我在 supervior conf 中配置的不一样啊,我用了参数-w 1 呀。
[2018-10-11 14:28:36 +0800] [25625] [ERROR] Connection in use: ('127.0.0.1', 5000)
[2018-10-11 14:28:36 +0800] [25625] [ERROR] Retrying in 1 second.
[2018-10-11 14:28:37 +0800] [25625] [INFO] Listening at: http://127.0.0.1:5000 (25625)
[2018-10-11 14:28:37 +0800] [25625] [INFO] Using worker: geventwebsocket.gunicorn.workers.GeventWebSocketWorker
[2018-10-11 14:28:37 +0800] [25635] [INFO] Booting worker with pid: 25635
[2018-10-11 14:32:15 +0800] [26148] [INFO] Starting gunicorn 19.9.0
[2018-10-11 14:32:15 +0800] [26148] [INFO] Listening at: http://127.0.0.1:5000 (26148)
[2018-10-11 14:32:15 +0800] [26148] [INFO] Using worker: geventwebsocket.gunicorn.workers.GeventWebSocketWorker
[2018-10-11 14:32:15 +0800] [26151] [INFO] Booting worker with pid: 26151
[2018-10-11 14:33:32 +0800] [26345] [INFO] Starting gunicorn 19.9.0
[2018-10-11 14:33:32 +0800] [26345] [INFO] Listening at: http://127.0.0.1:5000 (26345)
[2018-10-11 14:33:32 +0800] [26345] [INFO] Using worker: geventwebsocket.gunicorn.workers.GeventWebSocketWorker
[2018-10-11 14:33:32 +0800] [26348] [INFO] Booting worker with pid: 26348
[2018-10-11 14:37:35 +0800] [26931] [INFO] Starting gunicorn 19.9.0
[2018-10-11 14:37:35 +0800] [26931] [INFO] Listening at: http://127.0.0.1:5000 (26931)
[2018-10-11 14:37:35 +0800] [26931] [INFO] Using worker: geventwebsocket.gunicorn.workers.GeventWebSocketWorker
[2018-10-11 14:37:35 +0800] [26934] [INFO] Booting worker with pid: 26934
[2018-10-11 14:39:18 +0800] [27180] [INFO] Starting gunicorn 19.9.0
[2018-10-11 14:39:18 +0800] [27180] [INFO] Listening at: http://127.0.0.1:5000 (27180)
[2018-10-11 14:39:18 +0800] [27180] [INFO] Using worker: geventwebsocket.gunicorn.workers.GeventWebSocketWorker
[2018-10-11 14:39:18 +0800] [27183] [INFO] Booting worker with pid: 27183
1 ... 54  55  56  57  58  59  60  61  62  63  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   3869 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 24ms · UTC 05:15 · PVG 13:15 · LAX 22:15 · JFK 01:15
Developed with CodeLauncher
♥ Do have faith in what you're doing.