Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
@mitogen.main()
def main(router):
ansible_mitogen.affinity.policy.assign_muxprocess()
bigfile = tempfile.NamedTemporaryFile()
fill_with_random(bigfile, 1048576*512)
file_service = mitogen.service.FileService(router)
pool = mitogen.service.Pool(router, ())
file_service.register(bigfile.name)
pool.add(file_service)
try:
context = router.local()
run_test(router, bigfile, 'local()', context)
context.shutdown(wait=True)
context = router.sudo()
@mitogen.main()
def main(router):
f = router.fork()
f.call(do_nothing)
t0 = mitogen.core.now()
for x in xrange(20000):
f.call(do_nothing)
print('++', int(1e6 * ((mitogen.core.now() - t0) / (1.0+x))), 'usec')
@mitogen.main()
def main(router):
f = router.fork()
t0 = mitogen.core.now()
for x in range(1000):
f.call_service(service_name=MyService, method_name='ping')
print('++', int(1e6 * ((mitogen.core.now() - t0) / (1.0+x))), 'usec')
@mitogen.main()
def main(router):
t0 = mitogen.core.now()
for x in range(100):
t = mitogen.core.now()
f = router.local()# debug=True)
tt = mitogen.core.now()
print(x, 1000 * (tt - t))
print('%.03f ms' % (1000 * (mitogen.core.now() - t0) / (1.0 + x)))
@mitogen.main()
def main(router):
t0 = mitogen.core.now()
for x in xrange(200):
t = mitogen.core.now()
ctx = router.fork()
ctx.shutdown(wait=True)
print '++', 1000 * ((mitogen.core.now() - t0) / (1.0+x))
@mitogen.main(log_level='DEBUG')
def main(router):
if len(sys.argv) != 3:
print('usage: %s ' % sys.argv[0])
sys.exit(1)
blerp = fuse.FUSE(
operations=Operations(sys.argv[1]),
mountpoint=sys.argv[2],
foreground=True,
volname='%s (Mitogen)' % (sys.argv[1],),
)
@mitogen.main()
def main(router):
listener = mitogen.unix.Listener(router, path='/tmp/mitosock')
service = PingService(router)
service.run()
@mitogen.main()
def main(router):
# Start 5 subprocesses and give them made up names.
contexts = {
'host%d' % (i,): router.local()
for i in range(5)
}
# Used later to recover hostname. A future Mitogen will provide a better
# way to get app data references back out of its IO primitives, for now you
# need to do it manually.
hostname_by_context_id = {
context.context_id: hostname
for hostname, context in contexts.items()
}
# I am a select that holds the receivers that will receive the function