コード例 #1
0
ファイル: stub.py プロジェクト: ms705/ciel
write_fp = open(options.write_fifo, "w")
read_fp = open(options.read_fifo, "r", 0)
# Unbuffered so we can use select() on its FD for IO mux

user_script_namespaces = dict()

main_coro = stackless.coroutine.getcurrent()

while True:

    try:
        
        soft_cache.garbage_collect_cache()
        
        file_outputs = FileOutputRecords()
        message_helper = RpcHelper(read_fp, write_fp, file_outputs)
        file_outputs.set_message_helper(message_helper)
        
        print >>sys.stderr, "SkyPy: Awaiting task"
        entry_dict = message_helper.await_message("start_task")

        if skypy.current_task is None: # Otherwise we're in fixed mode -- this new task continues the old one
            
            user_script_namespace = user_script_namespaces.get(entry_dict["py_ref"].id, None)
            if user_script_namespace is None:
                runtime_response = skypy.fetch_ref(entry_dict["py_ref"], "open_ref", message_helper, make_sweetheart=True)
                source_filename = runtime_response["filename"]
                    
                user_script_namespace = imp.load_source(str("user_namespace_%s" % entry_dict["py_ref"].id), source_filename)
                user_script_namespaces[entry_dict["py_ref"].id] = user_script_namespace
            else:
コード例 #2
0
ファイル: interpreter_main.py プロジェクト: ms705/ciel
(options, args) = parser.parse_args()

if options.version:
    print "Ciel Skywriting v0.2. Python:"
    print sys.version
    sys.exit(0)
    
if options.write_fifo is None or options.read_fifo is None:
    print >>sys.stderr, "Skywriting: Must specify a read-fifo and a write-fifo."
    sys.exit(1)

write_fp = open(options.write_fifo, "w")
read_fp = open(options.read_fifo, "r")

message_helper = RpcHelper(read_fp, write_fp)

while True:

    try:
        task = SkywritingTask(message_helper, options.stdlib_base)
        task.run()
        message_helper.send_message("exit", {"keep_process": "may_keep"})
        
    except ShutdownException as e:
        print >>sys.stderr, "Skywriting: dying at Ciel's request. Given reason:", e.reason
        sys.exit(0) 
        
    except Exception as e:
        print >>sys.stderr, "Skywriting: dying due to exception at top level"
        message_helper.send_message("error", {"report": traceback.format_exc()})