本文整理汇总了Python中monocle.launch函数的典型用法代码示例。如果您正苦于以下问题:Python launch函数的具体用法?Python launch怎么用?Python launch使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了launch函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。
示例1: launch_proc_with_pipes
def launch_proc_with_pipes(target, *args, **kwargs):
log_child, log_parent = Pipe()
child, parent = Pipe()
args = [target, log_child, child] + list(args)
p = Process(target=_wrapper_with_pipes, args=args, kwargs=kwargs)
p.start()
launch(log_receive, PipeChannel(log_parent))
return p, parent
开发者ID:pombredanne,项目名称:monocle,代码行数:8,代码来源:sync.py
示例2: run
def run(self):
""" Calls the start event on the transport and initiates pumping between upstream and downstream connections in both directions. """
self.transport.start()
self.drain()
monocle.launch(self.pumpUpstream)
yield self.pumpDownstream()
开发者ID:blanu,项目名称:py-obfsproxy,代码行数:9,代码来源:pump.py
示例3: handle_dust
def handle_dust(conn):
print('handle_dust')
coder=yield handshake(conn)
client = Client()
yield client.connect('localhost', 9050)
monocle.launch(pump, conn, client, coder.decrypt)
yield pump(client, conn, coder.encrypt)
开发者ID:blanu,项目名称:Dust,代码行数:9,代码来源:dustSocksServer.py
示例4: main
def main():
ch = Channel() # Create a new channel.
monocle.launch(generate, ch) # Start generate() as an o-routine.
while True:
prime = yield ch.recv()
print prime
ch1 = Channel()
filter(ch, ch1, prime)
ch = ch1
开发者ID:ChrisWren,项目名称:monocle,代码行数:9,代码来源:sieve.py
示例5: handle_socksDust
def handle_socksDust(conn):
print('connection')
client = Client()
yield client.connect('blanu.net', 7051)
coder=yield handshake(client)
monocle.launch(pump, conn, client, coder.encrypt)
yield pump(client, conn, coder.decrypt)
开发者ID:blanu,项目名称:Dust,代码行数:9,代码来源:socksDustProxy.py
示例6: handle_dust
def handle_dust(conn):
print('handle_dust')
coder=yield handshake(conn)
buffer=FakeSocket()
monocle.launch(pump, conn, buffer, coder.decrypt)
monocle.launch(handle_socks, buffer.invert())
yield pump(buffer, conn, coder.encrypt, True)
print('done handling dust')
开发者ID:blanu,项目名称:Dust,代码行数:11,代码来源:dustSocksServer.py
示例7: main
def main():
"""
The prime sieve: Daisy-chain filter processes together.
"""
ch = Channel() # Create a new channel.
monocle.launch(generate, ch) # Start generate() as an o-routine.
while True:
prime = yield ch.recv()
print(prime)
ch1 = Channel()
filter(ch, ch1, prime)
ch = ch1
开发者ID:saucelabs,项目名称:monocle,代码行数:12,代码来源:sieve.py
示例8: launch_proc_with_sockets
def launch_proc_with_sockets(target, port, *args, **kwargs):
args = [target, port] + list(args)
p = Process(target=_wrapper_with_sockets, args=args, kwargs=kwargs)
p.start()
cb = Callback()
get_chan_service = partial(get_conn, cb)
service = Service(get_chan_service, port, bindaddr="127.0.0.1", backlog=1)
service._add()
conn = yield cb
yield service.stop()
chan = SocketChannel(conn)
main_chan, log_chan = make_subchannels(chan, ['main', 'log'])
launch(log_receive, log_chan)
yield Return(p, main_chan)
开发者ID:pombredanne,项目名称:monocle,代码行数:14,代码来源:sync.py
示例9: run
def run(self):
while self._running:
timeout = 0
if self._queue:
next = self._queue[-1][0] - time.time()
if next <= 0:
task = self._queue.pop()
launch(task[1], *task[2], **task[3])
else:
timeout = next
if self._map:
asyncore.loop(timeout=timeout, use_poll=True, count=1,
map=self._map)
else:
time.sleep(0.1)
开发者ID:ChrisWren,项目名称:monocle,代码行数:15,代码来源:eventloop.py
示例10: handle_socks
def handle_socks(conn):
print('connection')
yield readHandshake(conn)
yield sendHandshake(conn)
dest=yield readRequest(conn)
yield sendResponse(dest, conn)
addr, port=uncompact(dest)
print(addr)
print(port)
client = Client()
yield client.connect(addr, port)
monocle.launch(pump, conn, client)
yield pump(client, conn)
开发者ID:blanu,项目名称:Dust,代码行数:15,代码来源:socks_server.py
示例11: _handler
def _handler(request):
try:
value = yield launch(self.handler, request)
code, headers, content = extract_response(value)
except Exception:
log_exception()
code, headers, content = 500, {}, "500 Internal Server Error"
try:
if request._disconnected:
return
request.setResponseCode(code)
headers.setdefault('Server', 'monocle/%s' % VERSION)
grouped_headers = {}
for name, value in headers.iteritems():
if name in grouped_headers:
grouped_headers[name].append(value)
else:
grouped_headers[name] = [value]
for name, value in grouped_headers.iteritems():
request.responseHeaders.setRawHeaders(name, value)
request.write(content)
# close connections with a 'close' header
if headers.get('Connection', '').lower() == 'close':
request.channel.persistent = False
request.finish()
except Exception:
log_exception()
raise
开发者ID:sah,项目名称:monocle,代码行数:31,代码来源:http.py
示例12: _handler
def _handler(tornado_request):
try:
headers = HttpHeaders()
for k, v in tornado_request.headers.get_all():
headers.add(k, v)
body_file = io.BytesIO(tornado_request.body)
request = HttpRequest(proto=tornado_request.version,
host=tornado_request.host,
method=tornado_request.method,
uri=tornado_request.uri,
args=tornado_request.arguments,
remote_ip=tornado_request.remote_ip,
headers=headers,
body=tornado_request.body,
body_file=body_file)
request._tornado_request = tornado_request
value = yield launch(self.handle_request, request)
code, headers, content = extract_response(value)
except:
code, headers, content = 500, {}, "500 Internal Server Error"
tornado_request.write("HTTP/1.1 %s %s\r\n" %
(code, responses.get(code, 'Unknown')))
headers.setdefault('Server', 'monocle/%s' % VERSION)
headers.setdefault('Content-Length', str(len(content)))
for name, value in headers.iteritems():
tornado_request.write("%s: %s\r\n" % (name, value))
tornado_request.write("\r\n")
tornado_request.write(content)
tornado_request.finish()
开发者ID:steenzout,项目名称:monocle,代码行数:31,代码来源:http.py
示例13: _handler
def _handler(request):
try:
code, headers, content = yield launch(self.handler, request)
except Exception, e:
print type(e), str(e)
log.log_exception()
code, headers, content = 500, {}, "500 Internal Server Error"
开发者ID:pombredanne,项目名称:monocle,代码行数:7,代码来源:http.py
示例14: first_evlp
def first_evlp():
try:
yield sleep(1)
yield req()
yield launch(second)
finally:
eventloop.halt()
开发者ID:ChrisWren,项目名称:monocle,代码行数:7,代码来源:tb.py
示例15: run
def run(fn):
ctx = {'exit_code': 0}
@_o
def _run_async(ctx):
try:
yield fn()
except Exception:
traceback.print_exc(file=sys.stdout)
ctx['exit_code'] = 1
finally:
eventloop.halt()
launch(_run_async, ctx)
eventloop.run()
sys.exit(ctx['exit_code'])
开发者ID:saucelabs,项目名称:monocle,代码行数:16,代码来源:script_util.py
示例16: handle_socks
def handle_socks(conn):
print('handle_socks')
yield readHandshake(conn)
print('read handshake')
yield sendHandshake(conn)
print('send handshake')
dest=yield readRequest(conn)
print('read request: '+str(dest))
yield sendResponse(dest, conn)
print('sent response')
addr, port=uncompact(dest)
print(addr)
print(port)
client = Client()
yield client.connect(addr, port)
print('connected '+str(addr)+', '+str(port))
monocle.launch(pump, conn, client, None)
yield pump(client, conn, None)
开发者ID:blanu,项目名称:Dust,代码行数:20,代码来源:dustSocksServer.py
示例17: _handler
def _handler(request):
try:
code, headers, content = yield launch(self.handler, request)
except:
code, headers, content = 500, {}, "500 Internal Server Error"
request.setResponseCode(code)
headers.setdefault('Server', 'monocle/%s' % VERSION)
for name, value in headers.iteritems():
request.setHeader(name, value)
request.write(content)
request.finish()
开发者ID:bernii,项目名称:monocle,代码行数:11,代码来源:http.py
示例18: _handler
def _handler(request):
try:
code, headers, content = yield launch(self.handler, request)
except:
code, headers, content = 500, {}, "500 Internal Server Error"
request.write("HTTP/1.1 %s\r\n" % code)
headers.setdefault('Server', 'monocle/%s' % VERSION)
headers.setdefault('Content-Length', str(len(content)))
for name, value in headers.iteritems():
request.write("%s: %s\r\n" % (name, value))
request.write("\r\n")
request.write(content)
request.finish()
开发者ID:jlipps,项目名称:monocle,代码行数:13,代码来源:http.py
示例19: _handler
def _handler(request):
try:
value = yield launch(self.handler, request)
code, headers, content = extract_response(value)
except:
code, headers, content = 500, {}, "500 Internal Server Error"
request.write("HTTP/1.1 %s\r\n" % code)
headers.setdefault("Server", "monocle/%s" % VERSION)
headers.setdefault("Content-Length", str(len(content)))
for name, value in headers.iteritems():
request.write("%s: %s\r\n" % (name, value))
request.write("\r\n")
request.write(content)
request.finish()
开发者ID:niallo,项目名称:monocle,代码行数:14,代码来源:http.py
示例20: _handler
def _handler(request):
try:
value = yield launch(self.handle_request, request)
code, headers, content = extract_response(value)
except:
code, headers, content = 500, {}, "500 Internal Server Error"
request.write("HTTP/1.1 %s %s\r\n" %
(code, responses.get(code, 'Unknown')))
headers.setdefault('Server', 'monocle/%s' % VERSION)
headers.setdefault('Content-Length', str(len(content)))
for name, value in headers.iteritems():
request.write("%s: %s\r\n" % (name, value))
request.write("\r\n")
request.write(content)
request.finish()
开发者ID:ChrisWren,项目名称:monocle,代码行数:15,代码来源:http.py
注:本文中的monocle.launch函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论