代码拉取完成,页面将自动刷新
同步操作将从 搜狗开源/pyworkflow 强制同步,此操作会覆盖自 Fork 仓库以来所做的任何修改,且无法恢复!!!
确定后同步将在后台操作,完成时将刷新页面,请耐心等待。
start(port)
Workflow中关于Server Params的定义,wf.ServerParams的默认构造会返回SERVER_PARAMS_DEFAULT
struct WFServerParams
{
size_t max_connections;
int peer_response_timeout; /* timeout of each read or write operation */
int receive_timeout; /* timeout of receiving the whole message */
int keep_alive_timeout;
size_t request_size_limit;
int ssl_accept_timeout; /* if not ssl, this will be ignored */
};
static constexpr struct WFServerParams SERVER_PARAMS_DEFAULT =
{
.max_connections = 2000,
.peer_response_timeout = 10 * 1000,
.receive_timeout = -1,
.keep_alive_timeout = 60 * 1000,
.request_size_limit = (size_t)-1,
.ssl_accept_timeout = 10 * 1000,
};
# 获取Http body示例
import pywf as wf
def series_callback(x):
pass
def http_callback(x):
# x的类型是wf.HttpTask,作用域仅限于此函数内
# req 和 resp仅限于此函数中,函数结束时会立刻被回收
req = x.get_req()
resp = x.get_resp()
# 此时get_body获取到的是http请求的结果
# body的生命周期由Python管理,可以随意引用至函数外部
body = resp.get_body()
# print(body)
# 一般情况下不需要向resp里添加内容,若此时向resp追加内容,则请求结果会被清空,仅保留新追加的内容
resp.append_body("<html>") # 发生拷贝
resp.append_body(b"</html>") # 不会拷贝,bytes会被resp引用一份
print(resp.get_body()) # 输出 b'<html></html>'
def create_http_task():
return wf.create_http_task("http://www.sogou.com/", 1, 1, http_callback)
series = wf.create_series_work(create_http_task(), series_callback)
series.start()
wf.wait()
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。