【发布时间】:2011-09-28 05:14:29
【问题描述】:
我已经使用 web.py 实现了简单的网络服务器。 通过多线程模块,我可以运行多个监听不同端口的网络服务器实例。 现在所有的实例都在监听 http 请求。我想踩一个特定的线程。 有没有办法阻止实例监听(或完全杀死特定线程。)
【问题讨论】:
标签: web.py
我已经使用 web.py 实现了简单的网络服务器。 通过多线程模块,我可以运行多个监听不同端口的网络服务器实例。 现在所有的实例都在监听 http 请求。我想踩一个特定的线程。 有没有办法阻止实例监听(或完全杀死特定线程。)
【问题讨论】:
标签: web.py
api.py
import web
import threading
urls = (
'/', 'index',
)
class index:
def GET(self):
return "I'm lumberjack and i'm ok"
def run():
app = web.application(urls, globals())
t = threading.Thread(target=app.run)
t.setDaemon(True) # So the server dies with the main thread
t.setName('api-thread')
t.start()
frame.py
import sys
from PyQt4.QtCore import *
from PyQt4.QtGui import *
from PyQt4.QtWebKit import *
import api
app = QApplication(sys.argv)
web = QWebView()
api.run()
web.load(QUrl("http://0.0.0.0:8080/"))
web.show()
sys.exit(app.exec_())
【讨论】: