本文整理汇总了Python中twisted.internet.reactor.listenUNIX函数的典型用法代码示例。如果您正苦于以下问题:Python listenUNIX函数的具体用法?Python listenUNIX怎么用?Python listenUNIX使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了listenUNIX函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: startSocketServer
def startSocketServer(root_node, shutdownOnLastDisconnect, interactive, socket=None, extra_loggers=None):
"""
Bind the first available unix socket.
Return the socket file.
"""
# Create protocol factory.
factory = Factory()
factory.connectionPool = set() # List of currently, active connections
factory.protocol = CliClientProtocol
factory.shutdownOnLastDisconnect = shutdownOnLastDisconnect
factory.root_node = root_node
factory.interactive = interactive
factory.extra_loggers = extra_loggers or []
factory.runtime_options = Options()
# Listen on socket.
if socket:
reactor.listenUNIX(socket, factory)
else:
# Find a socket to listen on. (if no socket was given.)
i = 0
while True:
try:
socket = "/tmp/deployer.sock.%s.%i" % (getpass.getuser(), i)
reactor.listenUNIX(socket, factory)
break
except CannotListenError:
i += 1
# When 100 times failed, cancel server
if i == 100:
logging.warning("100 times failed to listen on posix socket. Please clean up old sockets.")
raise
return socket
开发者ID:JeffreyVdb,项目名称:python-deployer,代码行数:35,代码来源:socket_server.py
示例2: daemon_main
def daemon_main(self):
if config.logreqs:
self.logfile_access = logfile.DailyLogFile.fromFullPath(os.path.join(config.datadir, 'logs', 'access.log'))
else:
self.logfile_access = log.NullFile()
if config.debugmode:
if config.debugtostdout and config.nodaemon:
self.logfile_debug = sys.stdout
else:
self.logfile_debug = logfile.DailyLogFile.fromFullPath(os.path.join(config.datadir, 'logs', 'debug.log'))
else:
self.logfile_debug = log.NullFile()
log.startLogging(self.logfile_debug)
reactor.listenTCPonExistingFD = listenTCPonExistingFD
reactor.listenUNIX(os.path.join(config.rundir, 'rpc.socket'), factory=pb.PBServerFactory(self.rpc_server))
for i in range(config.processes):
subprocess = spawnT2W(self, self.childFDs, self.fds_https, self.fds_http)
self.subprocesses.append(subprocess.pid)
def MailException(etype, value, tb):
sendexceptionmail(config, etype, value, tb)
sys.excepthook = MailException
reactor.run()
开发者ID:Acidburn0zzz,项目名称:Tor2web-3.0,代码行数:30,代码来源:t2w.py
示例3: run
def run(self):
self.factory = HTTPFactory(
self.channel_layer,
self.action_logger,
timeout=self.http_timeout,
websocket_timeout=self.websocket_timeout,
ping_interval=self.ping_interval,
ws_protocols=self.ws_protocols,
root_path=self.root_path,
)
# Redirect the Twisted log to nowhere
globalLogBeginner.beginLoggingTo([lambda _: None], redirectStandardIO=False, discardBuffer=True)
# Listen on a socket
if self.unix_socket:
reactor.listenUNIX(self.unix_socket, self.factory)
elif self.file_descriptor:
# socket returns the same socket if supplied with a fileno
sock = socket.socket(fileno=self.file_descriptor)
reactor.adoptStreamPort(self.file_descriptor, sock.family, self.factory)
else:
reactor.listenTCP(self.port, self.factory, interface=self.host)
if "twisted" in self.channel_layer.extensions:
logging.info("Using native Twisted mode on channel layer")
reactor.callLater(0, self.backend_reader_twisted)
else:
logging.info("Using busy-loop synchronous mode on channel layer")
reactor.callLater(0, self.backend_reader_sync)
reactor.callLater(2, self.timeout_checker)
reactor.run(installSignalHandlers=self.signal_handlers)
开发者ID:bibinjose22,项目名称:daphne,代码行数:30,代码来源:server.py
示例4: test
def test():
if stat.S_ISSOCK(os.fstat(fastcgi.FCGI_LISTENSOCK_FILENO)[stat.ST_MODE]):
raise Exception('using pre-set fastcgi environment is not yet supported')
fac = twistedfcgi.FastCGIFactory(handler)
#reactor.listenTCP(8030, fac)
reactor.listenUNIX('fcgi.socket', fac)
reactor.run()
开发者ID:alexgirao,项目名称:fastcgi,代码行数:9,代码来源:fcgi-test3.py
示例5: run
def run():
service = Place
print("Start place_info Service")
reactor.listenUNIX(PLACEINFO_UNIX_DOMAIN, PlaceInfoFactory(service))
try:
reactor.run()
except Exception, err:
logger.info(err)
开发者ID:tyrchen,项目名称:kagalaska,代码行数:9,代码来源:place_info.py
示例6: run
def run():
service = TagRankService()
print("Start relation Service")
reactor.listenUNIX(RELATIONS_UNIX_DOMAIN, RelationFactory(service))
try:
reactor.run()
except Exception, err:
logger.info(err)
开发者ID:tyrchen,项目名称:kagalaska,代码行数:9,代码来源:relations.py
示例7: cbConnect
def cbConnect(self, directoryService):
"""
Callback from the directory service.
From this point we're connected and authenticated.
"""
basepath = FilePath(os.path.expanduser('~/.distfs'))
if not basepath.exists():
basepath.createDirectory()
store = FileSystemStore(basepath.child('store').path)
chunkFactory = Site(server.StoreResource(store))
locname = self['alias'] or directoryService.service
# Listen for remote connections. This is for the other nodes
# to access our store.
port = self['port'] and int(self['port']) or 0
listeningPort = reactor.listenTCP(port, chunkFactory)
keyStore = SQLiteDataStore(basepath.child('%s.db' % locname).path)
dhtNode = KademliaNode(listeningPort.getHost().port, keyStore,
reactor=reactor)
# Listen locally so that applications can easily access the
# store.
reactor.listenUNIX(basepath.child('%s.http' % locname).path,
chunkFactory)
resolverPublisher = ResolverPublisher(dhtNode)
controlFactory = control.ControlFactory(store, directoryService,
dhtNode, resolverPublisher)
reactor.listenUNIX(basepath.child('%s.ctrl' % locname).path,
controlFactory)
# Start a looping call that will publish chunks to the
# overlay; do that every 6th hour. Delay the procedure a bit
# so that the node has a chance to join the network.
looping = task.LoopingCall(publishChunks, store, resolverPublisher)
reactor.callLater(10, looping.start, 6*60*60, True)
# Try joining the network.
introducers = list()
if self['introducer']:
try:
address, port = self['introducer'].split(':')
except ValueError:
address, port = self['introducer'], 8033
introducers.append((address, int(port)))
dhtNode.joinNetwork(introducers)
# At this point everything that can go (majorly) wrong has
# been initialized and we can daemonize.
if not self['no-daemon']:
daemonize()
开发者ID:jrydberg,项目名称:distfs,代码行数:56,代码来源:script.py
示例8: __init__
def __init__(self, command_cb, address = None, sock_owner = None):
self.command_cb = command_cb
self.protocol = Cli_session
if address == None:
address = '/var/run/ccm.sock'
if exists(address):
unlink(address)
reactor.listenUNIX(address, self)
if sock_owner != None:
chown(address, sock_owner[0], sock_owner[1])
开发者ID:DarthRa,项目名称:pulsar,代码行数:10,代码来源:Cli_server_local.py
示例9: run
def run():
wordseg = WordSegService()
relations = TagService()
print("Start WordSeg Service")
reactor.listenUNIX(WORDSEG_UNIX_DOMAIN, WordSegFactory(wordseg, relations))
try:
reactor.run()
except Exception, err:
logger.info(err)
开发者ID:tyrchen,项目名称:kagalaska,代码行数:10,代码来源:tag_rank.py
示例10: autostart
def autostart(reason, **kwargs):
if reason == 0:
from twisted.internet import reactor
try:
os.remove("/tmp/hotplug.socket")
except OSError:
pass
factory = Factory()
factory.protocol = Hotplug
reactor.listenUNIX("/tmp/hotplug.socket", factory)
开发者ID:dazulrich,项目名称:dvbapp,代码行数:10,代码来源:plugin.py
示例11: _run_manhole
def _run_manhole(self):
# This condition is made with the assumption that no existing daemon
# is running. If there is one, the following code could potentially
# cause problems for the other daemon by removing its socket.
if os.path.exists(self.manhole_sock):
log.info('Removing orphaned manhole socket')
os.remove(self.manhole_sock)
self.manhole = make_manhole(dict(trond=self, mcp=self.mcp))
reactor.listenUNIX(self.manhole_sock, self.manhole)
log.info(f"manhole started on {self.manhole_sock}")
开发者ID:Yelp,项目名称:Tron,代码行数:11,代码来源:trondaemon.py
示例12: run
def run(self):
"""
Start the server and listen on host:port
"""
f = None
unix_prefix = 'unix://'
if self.http_enabled:
rpc = JsonRpcHttpResource()
rpc.rpcprocessor = self.rpcprocessor
rpc.tls_client_auth_enabled = self.tls_client_auth_enabled
if self.http_basic_auth_enabled:
checker = PasswordChecker(self.passwdCheckFunction)
realm = HttpPasswordRealm(rpc)
p = portal.Portal(realm, [checker])
realm_name = 'Reflect RPC'
if sys.version_info.major == 2:
realm_name = realm_name.encode('utf-8')
credentialFactory = BasicCredentialFactory(realm_name)
rpc = HTTPAuthSessionWrapper(p, [credentialFactory])
root = RootResource(rpc)
f = server.Site(root)
else:
f = JsonRpcProtocolFactory(self.rpcprocessor,
self.tls_client_auth_enabled)
if self.tls_enabled:
if not self.tls_client_auth_enabled:
reactor.listenSSL(self.port, f, self.cert.options(),
interface=self.host)
else:
reactor.listenSSL(self.port, f,
self.cert.options(self.client_auth_ca),
interface=self.host)
else:
if self.host.startswith(unix_prefix):
path = self.host[len(unix_prefix):]
reactor.listenUNIX(path, f, backlog=self.unix_socket_backlog,
mode=self.unix_socket_mode, wantPID=self.unix_socket_want_pid)
else:
reactor.listenTCP(self.port, f, interface=self.host)
if self.host.startswith(unix_prefix):
print("Listening on %s" % (self.host))
else:
print("Listening on %s:%d" % (self.host, self.port))
reactor.run()
开发者ID:aheck,项目名称:reflectrpc,代码行数:54,代码来源:twistedserver.py
示例13: listen
def listen(self):
server = ModuleServer(self.options.module)
# ensure that the UNIX socket is only accessable by root
old_umask = umask(0077)
try:
reactor.listenUNIX(self.options.socket, server)
finally:
umask(old_umask)
notifier.loop()
开发者ID:spaceone,项目名称:univention-management-console,代码行数:11,代码来源:daemon.py
示例14: main
def main():
args = sys.argv[1: ]
config = Config(args)
comet_server = CometServer(config)
site = server.Site(comet_server, timeout = config.http_timeout)
if config.http_port != None:
reactor.listenTCP(config.http_port, site)
if config.unix_socket_path != None:
reactor.listenUNIX(config.unix_socket_path, site)
reactor.run()
开发者ID:carriercomm,项目名称:Simple-Comet-Server,代码行数:12,代码来源:simple_comet.py
示例15: autostart
def autostart(reason, **kwargs):
if reason == 0:
print "starting hotplug handler"
factory = Factory()
factory.protocol = Hotplug
try:
import os
os.remove("/tmp/hotplug.socket")
except OSError:
pass
reactor.listenUNIX("/tmp/hotplug.socket", factory)
开发者ID:FFTEAM,项目名称:enigma2-5,代码行数:13,代码来源:plugin.py
示例16: start_server
def start_server():
startLogging(sys.stdout)
serverFactory = protocol.ServerFactory()
serverFactory.protocol = WaitForQueries
try:
remove(pipe_filepath)
except:
pass
reactor.listenUNIX(pipe_filepath, serverFactory)
reactor.run()
开发者ID:dsoprea,项目名称:TvServer,代码行数:13,代码来源:server.py
示例17: main
def main():
# Parse options
parser = OptionParser()
parser.add_option(
"--config-file", help="Path to configuration file", default=os.path.expanduser("~/.config/melissi/config")
)
parser.add_option("--no-desktop", help="Disable desktop", action="store_true", default=False)
parser.add_option(
"-v",
"--verbosity",
help="Verbose debug messages. Use multiple for more verbose messages",
action="count",
dest="verbosity",
default=0,
)
(options, _) = parser.parse_args()
# parse verbosity level and set logging
if options.verbosity == 0:
setup_logging(20)
elif options.verbosity == 1:
setup_logging(10)
elif options.verbosity == 2:
setup_logging(5)
elif options.verbosity >= 3:
setup_logging(4)
elif options.quiet == True:
setup_logging(30)
hub = Hub()
hub.queue = queue.Queue(hub)
hub.config_manager = config.ConfigManager(hub, os.path.expanduser(options.config_file))
hub.database_manager = database.DatabaseManager(hub, hub.config_manager.get_database())
hub.notify_manager = notifier.NotifyManager(hub)
hub.desktop_tray = desktop.DesktopTray(
hub, disable=hub.config_manager.config.get("main", "no-desktop") == "True" or options.no_desktop
)
hub.worker = worker.Worker(hub)
hub.rest_client = restclient.RestClient(hub)
hub.watch_dog = watchdog.WatchDog(hub)
# enable commander
command_receiver = commander.FooboxCommandReceiver(hub)
socket_path = hub.config_manager.get_socket()
if socket_path:
try:
reactor.listenUNIX(socket_path, command_receiver)
except twisted.internet.error.CannotListenError, error_message:
print "Cannot use this socket. Please specify another socket"
sys.exit(1)
开发者ID:akatsoulas,项目名称:client,代码行数:51,代码来源:melissi_client.py
示例18: create_server
def create_server(q, address_type, factory=None, block_reading=False,
streamfile='stream'):
if factory is None:
factory = EventProtocolFactory(q, block_reading)
if address_type == cs.SOCKET_ADDRESS_TYPE_UNIX:
path = os.getcwd() + '/' + streamfile
try:
os.remove(path)
except OSError, e:
if e.errno != errno.ENOENT:
raise
reactor.listenUNIX(path, factory)
return dbus.ByteArray(path)
开发者ID:dfghj44444,项目名称:realxtend-naali-deps,代码行数:14,代码来源:tubetestutil.py
示例19: kajonggServer
def kajonggServer():
"""start the server"""
from optparse import OptionParser
parser = OptionParser()
defaultPort = InternalParameters.defaultPort()
parser.add_option('', '--port', dest='port',
help=m18n('the server will listen on PORT (%d)' % defaultPort),
type=int, default=defaultPort)
parser.add_option('', '--socket', dest='socket',
help=m18n('the server will listen on SOCKET'), default=None)
parser.add_option('', '--db', dest='dbpath', help=m18n('name of the database'), default=None)
parser.add_option('', '--local', dest='local', action='store_true',
help=m18n('start a local game server'), default=False)
parser.add_option('', '--continue', dest='continueServer', action='store_true',
help=m18n('do not terminate local game server after last client disconnects'), default=False)
parser.add_option('', '--debug', dest='debug',
help=Debug.help())
(options, args) = parser.parse_args()
if args and ''.join(args):
logWarning(m18n('unrecognized arguments:%1', ' '.join(args)))
sys.exit(2)
InternalParameters.continueServer |= options.continueServer
if options.dbpath:
InternalParameters.dbPath = os.path.expanduser(options.dbpath)
if options.local:
InternalParameters.socket = socketName()
if options.socket:
InternalParameters.socket = options.socket
Debug.setOptions(options.debug)
Query.dbhandle = initDb()
realm = MJRealm()
realm.server = MJServer()
kajonggPortal = portal.Portal(realm, [DBPasswordChecker()])
# pylint: disable=E1101
# pylint thinks reactor is missing listen* and run
loadPredefinedRulesets()
try:
if InternalParameters.socket:
if os.name == 'nt':
logInfo('local server listening on 127.0.0.1 port %d' % options.port)
reactor.listenTCP(options.port, pb.PBServerFactory(kajonggPortal),
interface='127.0.0.1')
else:
logInfo('local server listening on UNIX socket %s' % InternalParameters.socket)
reactor.listenUNIX(InternalParameters.socket, pb.PBServerFactory(kajonggPortal))
else:
logInfo('server listening on port %d' % options.port)
reactor.listenTCP(options.port, pb.PBServerFactory(kajonggPortal))
except error.CannotListenError, errObj:
logWarning(errObj)
开发者ID:jsj2008,项目名称:kdegames,代码行数:50,代码来源:server.py
示例20: do_setup
def do_setup(self):
props = self.config['properties']
self.socketPath = props.get('path')
self.factory = UnixDomainDumbFactory(self)
# We need to set the pipeline to READY so the multifdsink gets started
self.pipeline.set_state(gst.STATE_READY)
# remove the existing socket
if os.path.exists(self.socketPath):
os.unlink(self.socketPath)
self.log("Starting to listen on UNIX : %s" % self.socketPath)
reactor.listenUNIX(self.socketPath, self.factory)
开发者ID:ApsOps,项目名称:flumotion-orig,代码行数:14,代码来源:unixdomain.py
注:本文中的twisted.internet.reactor.listenUNIX函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论