我希望有一个扭曲的服务(通过twistd启动),它监听指定IP地址上指定端口上的TCP/POST请求.到目前为止,我有一个扭曲的应用程序,它侦听localhost上的端口8040.它运行正常,但我希望它只收听某个IP地址,比如10.0.0.78.
怎么管理?这是我的代码片段:
application = service.Application('SMS_Inbound')
smsInbound = resource.Resource()
smsInbound.putChild('75sms_inbound',ReceiveSMS(application))
smsInboundServer = internet.TCPServer(8001, webserver.Site(smsInbound))
smsInboundServer.setName("SMS Handling")
smsInboundServer.setServiceParent(application)
Run Code Online (Sandbox Code Playgroud) 我想获取类的方法的关键字参数的名称.我想我明白了如何获取方法的名称以及如何获取特定方法的变量名称,但我不知道如何组合这些:
class A(object):
def A1(self, test1=None):
self.test1 = test1
def A2(self, test2=None):
self.test2 = test2
def A3(self):
pass
def A4(self, test4=None, test5=None):
self.test4 = test4
self.test5 = test5
a = A()
# to get the names of the methods:
for methodname in a.__class__.__dict__.keys():
print methodname
# to get the variable names of a specific method:
for varname in a.A1.__func__.__code__.co_varnames:
print varname
# I want to have something like this:
for function in class:
print function.name
for varname in function:
print …Run Code Online (Sandbox Code Playgroud)