本文整理汇总了Python中circuits.Manager.run方法的典型用法代码示例。如果您正苦于以下问题:Python Manager.run方法的具体用法?Python Manager.run怎么用?Python Manager.run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类circuits.Manager
的用法示例。
在下文中一共展示了Manager.run方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: main
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
def main():
setprocname(basename(sys.argv[0]))
config = Config()
chdir(config["rootdir"])
logger = setup_logging(config)
manager = Manager()
Worker(channel="workers").register(manager)
if config["debug"]:
Debugger(
logger=logger,
events=config["verbose"],
).register(manager)
Core(config).register(manager)
try:
manager.run()
finally:
config.save()
示例2: main
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
def main():
opts, args = parse_options()
if ":" in opts.bind:
address, port = opts.bind.split(":")
port = int(port)
else:
address, port = opts.bind, 8000
if args:
x = args[0].split(":")
if len(x) > 1:
nodes = [(x[0], int(x[1]))]
else:
nodes = [(x[0], 8000)]
else:
nodes = []
manager = Manager()
debugger = Debugger()
debugger.IgnoreEvents.extend(["Read", "Write"])
manager += debugger
bridge = Bridge(port, address=address, nodes=nodes)
manager += bridge
manager.run()
示例3: main
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
def main():
opts, args = parse_options()
bind = parse_bind(opts.bind)
if opts.validate:
application = (Application() + Root())
app = validator(application)
httpd = make_server(bind[0], bind[1], app)
httpd.serve_forever()
raise SystemExit(0)
manager = Manager()
opts.debug and Debugger().register(manager)
Poller = select_poller(opts.poller.lower())
Poller().register(manager)
if opts.server.lower() == "base":
BaseServer(bind).register(manager)
HelloWorld().register(manager)
else:
Server(bind).register(manager)
Root().register(manager)
docroot = os.getcwd() if not args else args[0]
Static(docroot=docroot, dirlisting=True).register(manager)
opts.passwd and Authentication(passwd=opts.passwd).register(manager)
opts.logging and Logger().register(manager)
if opts.profile and hotshot:
profiler = hotshot.Profile(".profile")
profiler.start()
if opts.debug:
print(graph(manager, name="circuits.web"))
print()
print(inspect(manager))
for i in range(opts.jobs):
manager.start(process=True)
manager.run()
if opts.profile and hotshot:
profiler.stop()
profiler.close()
stats = hotshot.stats.load(".profile")
stats.strip_dirs()
stats.sort_stats("time", "calls")
stats.print_stats(20)
示例4: main
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
def main():
config = Config()
manager = Manager()
if config.get("debug"):
manager += Debugger(events=config.get("verbose"), file=config.get("errorlog"))
environ = Environment(config)
SignalHandler(environ).register(environ)
manager += environ
if config.get("sock") is not None:
bind = config.get("sock")
elif ":" in config.get("bind"):
address, port = config.get("bind").split(":")
bind = (address, int(port))
else:
bind = (config.get("bind"), config.get("port"))
server = Server(bind) + Sessions() + Root(environ) + CacheControl(environ) + ErrorHandler(environ)
if MemoryMonitor is not None:
MemoryMonitor(channel="/memory").register(server)
if not config.get("disable-logging"):
server += Logger(file=config.get("accesslog", sys.stdout))
if not config.get("disable-static"):
server += Static(docroot=os.path.join(config.get("theme"), "htdocs"))
if not config.get("disable-hgweb"):
baseui = ui()
baseui.setconfig("web", "prefix", "/+hg")
baseui.setconfig("web", "style", "gitweb")
baseui.setconfig("web", "allow_push", "*")
baseui.setconfig("web", "push_ssl", False)
baseui.setconfig("web", "allow_archive", ["bz2", "gz", "zip"])
baseui.setconfig("web", "description", config.get("description"))
server += Gateway({"/+hg": hgweb(environ.storage.repo_path, config.get("name"), baseui)})
if not config.get("disable-compression"):
server += Compression(environ)
if config.get("daemon"):
manager += Daemon(config.get("pidfile"))
server.register(manager)
manager.run()
示例5: main
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
def main():
config = Config()
logger = setup_logging(config)
db = setup_database(config, logger)
manager = Manager()
Worker(channel="threadpool").register(manager)
if config["debug"]:
Debugger(logger=logger, events=config["verbose"]).register(manager)
if config["daemon"]:
Daemon(config["pidfile"]).register(manager)
Core(config, db).register(manager)
manager.run()
示例6: main
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
def main():
setprocname(basename(sys.argv[0]))
config = Config()
manager = Manager()
Worker(channel="workerthreads").register(manager)
Worker(channel="workerprocesses").register(manager)
if config.get("debug"):
Debugger(
events=config.get("verbose"),
file=config.get("errorlog")
).register(manager)
if config.get("daemon"):
manager += Daemon(config.get("pidfile"))
Core(config).register(manager)
manager.run()
示例7: Manager
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
mylogger.addHandler(h)
m = Manager()
logging.debug("manager init")
m += Debugger()
logging.debug("debugger init + register")
# l = Logger()
# Config.__dict__['__metaclass__'] = HandlerMetaClass
# Config = HandlerMetaClass('Config', (_Config,), {})
c = Config(sys.argv[1])
print("\n\n")
print(c.name)
pprint(c._handlers)
print("\n\n")
# m += l
m += c
m.fire(Load(), target="config")
# while m: m.flush()
logging.debug("config init + register")
p = plugin_manager(paths=sys.argv[2])
logging.debug("pm init")
m += p
logging.debug("pm register")
# while m: m.flush()
# (Manager() + Logger() + Config(sys.argv[1]) + plugin_manager(paths=sys.argv[2])).run()
# while m: m.flush()
m.fire(Event(collect_plugin), "load", target="plugin_manager")
# p.load(collect_plugin)
logging.debug("pm load")
m.run()
示例8: test2
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
def test2():
import gobject
from circuits import Manager, Debugger
from circuits.net.sockets import TCPClient, Connect, Write
m = Manager()
m += GtkDriver()
m += Debugger()
def on_delete(window, event):
m.stop()
w = gtk.Window()
w.connect('delete-event', on_delete)
vb = gtk.VBox()
b = gtk.Button('Click me')
tv = gtk.TextView()
sw = gtk.ScrolledWindow()
sw.add(tv)
vb.pack_start(sw)
class Wget(TCPClient):
channel = "wget"
def __init__(self, tv, host='google.com', port=80):
super(Wget, self).__init__()
self.tv = tv
self += TCPClient(channel=self.channel)
def fetch_google(self, *args):
self.push(Connect('google.com', 80), "connect")
def connected(self, host, port):
print "Connected to %s" % host
self.push(Write('GET / HTTP/1.0\r\n\r\n'))
def error(self, *args):
print "ERROR: %r" % list(args)
def read(self, data):
def _write(data):
self.tv.get_buffer().set_text(data)
gobject.idle_add(_write, data)
wg = Wget(tv)
m += wg
def on_click(self, wget):
tv.get_buffer().set_text('')
wget.fetch_google()
b.connect('clicked', on_click, wg)
vb.pack_start(b, expand=False)
w.add(vb)
w.show_all()
print graph(m)
print inspect(m)
m.run()
示例9: main
# 需要导入模块: from circuits import Manager [as 别名]
# 或者: from circuits.Manager import run [as 别名]
def main():
opts, args = parse_options()
if opts.jit and psyco:
psyco.full()
if ":" in opts.bind:
address, port = opts.bind.split(":")
port = int(port)
else:
address, port = opts.bind, 8000
bind = (address, port)
if opts.validate:
application = (wsgi.Application() + Root())
app = validator(application)
httpd = make_server(address, port, app)
httpd.serve_forever()
raise SystemExit, 0
manager = Manager()
if opts.debug:
manager += Debugger()
poller = opts.type.lower()
if poller == "poll":
Poller = Poll
elif poller == "epoll":
if EPoll is None:
print "No epoll support available - defaulting to Select..."
Poller = Select
else:
Poller = EPoll
else:
Poller = Select
if opts.server.lower() == "base":
manager += (BaseServer(bind, poller=Poller) + HelloWorld())
else:
manager += (Server(bind, poller=Poller) + Root())
if opts.profile:
if hotshot:
profiler = hotshot.Profile(".profile")
profiler.start()
if opts.debug:
print graph(manager, name="circuits.web")
print
print inspect(manager)
if opts.mp:
from circuits.core.workers import cpus
for i in xrange(cpus() - 1):
manager.start(process=True)
manager.run()
if opts.profile and hotshot:
profiler.stop()
profiler.close()
stats = hotshot.stats.load(".profile")
stats.strip_dirs()
stats.sort_stats("time", "calls")
stats.print_stats(20)