gpt4 book ai didi

python - 扭曲的 ReconnectingClientFactory 失败且没有错误

转载 作者:太空宇宙 更新时间:2023-11-03 18:05:32 25 4
gpt4 key购买 nike

今天我为您提供的是以下日志:

2014-11-17 08:26:35-0500 [-] Log opened.
2014-11-17 08:26:35-0500 [-] twistd 14.0.2 (/usr/bin/python 2.7.8) starting up.
2014-11-17 08:26:35-0500 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2014-11-17 08:26:35-0500 [-] Starting factory <crawl_client.WhoisClientProtocolFactory instance at 0x7fc162a36440>
2014-11-17 08:26:35-0500 [Uninitialized] <twisted.internet.tcp.Connector instance at 0x7fc168b7fe60> will retry in 2 seconds
2014-11-17 08:26:35-0500 [Uninitialized] Stopping factory <crawl_client.WhoisClientProtocolFactory instance at 0x7fc162a36440>
2014-11-17 08:26:37-0500 [-] Starting factory <crawl_client.WhoisClientProtocolFactory instance at 0x7fc162a36440>
2014-11-17 08:26:37-0500 [Uninitialized] <twisted.internet.tcp.Connector instance at 0x7fc168b7fe60> will retry in 4 seconds
2014-11-17 08:26:37-0500 [Uninitialized] Stopping factory <crawl_client.WhoisClientProtocolFactory instance at 0x7fc162a36440>
2014-11-17 08:26:42-0500 [-] Starting factory <crawl_client.WhoisClientProtocolFactory instance at 0x7fc162a36440>
2014-11-17 08:26:42-0500 [Uninitialized] <twisted.internet.tcp.Connector instance at 0x7fc168b7fe60> will retry in 14 seconds
2014-11-17 08:26:42-0500 [Uninitialized] Stopping factory <crawl_client.WhoisClientProtocolFactory instance at 0x7fc162a36440>
2014-11-17 08:26:57-0500 [-] Starting factory <crawl_client.WhoisClientProtocolFactory instance at 0x7fc162a36440>

这是工厂代码:

from twisted.internet.protocol import ReconnectingClientFactory
from uuid import uuid4

class WhoisClientProtocolFactory(ReconnectingClientFactory):

def __init__(self, clientName='', maxDelay=60):
# attach a name with the client to identify itself to the server
if not clientName:
clientName = str(uuid4())[:8] # first 8 characters from a random string
self.client_name = clientName
self.maxDelay = maxDelay
logFromClient("client started", logging.INFO, clientName)

def buildProtocol(self, addr):
self.resetDelay()
return MyClientProtocol(self.client_name)

这段代码在我的测试机上运行良好。当部署在服务器上时,它会绕圈走。我怎样才能找到造成这种情况的原因?顺便说一句,客户端基于 LineReceiver

谢谢

最佳答案

当连接尝试失败时,工厂的 clientConnectionFailed方法被调用。 ReconnectingClientFactory 实现此方法以添加重试行为和您看到的给出退避超时的最小日志记录。

您也可以重写此方法。引入您想要的额外日志记录 - 连接失败的原因作为参数传递给此方法 - 然后调用基本实现(以保留重试行为)。

原因为 Failure实例。

关于python - 扭曲的 ReconnectingClientFactory 失败且没有错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26974119/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com