V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  4ever911  ›  全部回复第 36 页 / 共 38 页
回复总数  743
1 ... 28  29  30  31  32  33  34  35  36  37 ... 38  
2016-11-13 00:55:38 +08:00
回复了 4ever911 创建的主题 Python Python 多线程 Websockets 退出出错
好像还是用抛异常来解决超时杀线程比较方便


import threading
import time
import inspect
import ctypes

def _async_raise(tid, exctype):
"""raises the exception, performs cleanup if needed"""
tid = ctypes.c_long(tid)
if not inspect.isclass(exctype):
exctype = type(exctype)
res = ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, ctypes.py_object(exctype))
if res == 0:
raise ValueError("invalid thread id")
elif res != 1:
# """if it returns a number greater than one, you're in trouble,
# and you should call it again with exc=NULL to revert the effect"""
ctypes.pythonapi.PyThreadState_SetAsyncExc(tid, None)
raise SystemError("PyThreadState_SetAsyncExc failed")

def stop_thread(thread):
_async_raise(thread.ident, SystemExit)

class TestThread(threading.Thread):
def run(self):
print "begin"
while True:
time.sleep(0.1)
print "end"
if __name__ == "__main__":
t = TestThread()
t.start()
time.sleep(1)
stop_thread(t)
print "stoped"
2016-11-12 21:50:01 +08:00
回复了 4ever911 创建的主题 Python Python 多线程 Websockets 退出出错
@raysonx 你可能没仔细看上面的帖子, 也可能我没说清楚。

1. python 不像 c++那样提供强制退出线程的函数。 有的时候,你 CTRL+C ,主程序退出了, 你用 Process Monitor 海能看到有代码在跑。

2. 我设置了这样的变量让他退出, 现在关键是 recv 那个函数阻塞住不返回, 也就不会去访问那个变量。我尝试设置超时,也可能是我设置有问题。 对 Python 的异步还没完全搞明白。
楼上有人要 GR2 吗, 买了没用几次,想出,还有 Leica x1 ,也便宜出。
2016-10-21 11:11:14 +08:00
回复了 4ever911 创建的主题 云计算 Cloud 主机硬件选择问题
主要是跑 Python 程序, 太多核好像也用不到, 比较讨厌的一点是, CPU 和 RAM 通常不能自定义配置比例。
2016-10-10 15:20:36 +08:00
回复了 qceytzn 创建的主题 Linux 有没有人比较过 debian 8 和 ubuntu 16 的稳定性?
稳定和速度快慢是两回事, 并且你都不确定源是不是一样..

少年, 看问题看本质....
2016-10-08 23:07:35 +08:00
回复了 KOSKERS 创建的主题 Linux 在 Youtube 上看到老外用 unity8.看上去挺帅气的。
@su8610 I don't think so. There are so many bugs.
@zhuangzhuang1988

Please see code below:


```python

from PyQt4 import QtGui, QtCore
import sys
import time

app = QtGui.QApplication(sys.argv)

#the following line will crash the app
time.sleep(300)

w = QtGui.QDialog()
w.show()

sys.exit(app.exec_())

```python


Error Message: ICE default IO error handler doing an exit(), pid = 31805, errno = 32


In some certain occasion, when tasks that take so much time for running, such as loading a database...etc, the app crashes either. To make it simple here, I just added a short period of time sleep to the source code, which crashes the app.


Sorry about that I cannot type Chinese on my Linux Server.
2016-10-08 15:14:41 +08:00
回复了 KOSKERS 创建的主题 Linux 在 Youtube 上看到老外用 unity8.看上去挺帅气的。
xfce user pass by...
我现在发帖用的是一台 外星人 Alpha ,装的 Xubuntu ,速度飞快!但是实际上显卡是多余的,根本用不到,并且支持也不够。

一个星期前,我一直犹豫要不要买一台顶配 32G 的骷髅 做我家里的服务器,也是装 linux , 最后,选择了 i5 的 nuc
因为一个显卡用不到, 二来, i5 完全满足我需求,而且低耗电, CPU 温度低,长期跑稳定。

关键是,价格便宜不少啊。
2016-10-06 16:04:14 +08:00
回复了 tabris17 创建的主题 程序员 ZeroMQ 作者于昨天下午宣布安乐死
R.I.P

能留下一些东西已经很棒了!
2016-10-05 14:58:06 +08:00
回复了 4ever911 创建的主题 Python Python Thread/gevent 等待 Event 完成,主线程被锁
@binux 丢给进程处理,也要在 thread.join() 等待完成吧。还是会 block 掉主线程吧,我回头试试看。
2016-10-04 20:13:47 +08:00
回复了 4ever911 创建的主题 Python Python Thread/gevent 等待 Event 完成,主线程被锁
现在问题是我不可能去修改那部分 cpp 代码
2016-09-26 22:37:38 +08:00
回复了 tsl0922 创建的主题 分享创造 终端分享工具 ttyd 发布首个正式版本 1.0.0
类似 web 版本 ssh 吗
2016-09-23 01:21:10 +08:00
回复了 4ever911 创建的主题 Python 我也来问个 gevent 的 threadpool 问题
用错了,应该用 pool 而不是 thread pool
2016-09-23 00:52:22 +08:00
回复了 4ever911 创建的主题 Python 我也来问个 gevent 的 threadpool 问题
可以关闭了。。。。

可以关闭了。。。。

可以关闭了。。。。
2016-09-23 00:50:25 +08:00
回复了 4ever911 创建的主题 Python 我也来问个 gevent 的 threadpool 问题
开发者真牛 x ,我发了消息,马上秒回。

jamadden commented :

A ThreadPool uses native threads, so you have exactly the same concerns that you'd have with any use of native threads.

You probably don't want to use a ThreadPool here anyway, I doubt it's going to gain you any additional concurrency over what gevent already provides.
2016-09-23 00:18:33 +08:00
回复了 4ever911 创建的主题 Python 我也来问个 gevent 的 threadpool 问题
我转发到 github 的开发组上面去问看看
1 ... 28  29  30  31  32  33  34  35  36  37 ... 38  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5313 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 45ms · UTC 07:52 · PVG 15:52 · LAX 00:52 · JFK 03:52
Developed with CodeLauncher
♥ Do have faith in what you're doing.