MCPcopy Create free account
hub / github.com/RT-Thread/env-windows / main

Function main

tools/python-3.11.9-amd64/Lib/idlelib/run.py:110–186  ·  view source on GitHub ↗

Start the Python execution server in a subprocess In the Python subprocess, RPCServer is instantiated with handlerclass MyHandler, which inherits register/unregister methods from RPCHandler via the mix-in class SocketIO. When the RPCServer 'server' is instantiated, the TCPSer

(del_exitfunc=False)

Source from the content-addressed store, hash-verified

108interruptable = False
109
110def main(del_exitfunc=False):
111 """Start the Python execution server in a subprocess
112
113 In the Python subprocess, RPCServer is instantiated with handlerclass
114 MyHandler, which inherits register/unregister methods from RPCHandler via
115 the mix-in class SocketIO.
116
117 When the RPCServer 'server' is instantiated, the TCPServer initialization
118 creates an instance of run.MyHandler and calls its handle() method.
119 handle() instantiates a run.Executive object, passing it a reference to the
120 MyHandler object. That reference is saved as attribute rpchandler of the
121 Executive instance. The Executive methods have access to the reference and
122 can pass it on to entities that they command
123 (e.g. debugger_r.Debugger.start_debugger()). The latter, in turn, can
124 call MyHandler(SocketIO) register/unregister methods via the reference to
125 register and unregister themselves.
126
127 """
128 global exit_now
129 global quitting
130 global no_exitfunc
131 no_exitfunc = del_exitfunc
132 #time.sleep(15) # test subprocess not responding
133 try:
134 assert(len(sys.argv) > 1)
135 port = int(sys.argv[-1])
136 except:
137 print("IDLE Subprocess: no IP port passed in sys.argv.",
138 file=sys.__stderr__)
139 return
140
141 capture_warnings(True)
142 sys.argv[:] = [""]
143 threading.Thread(target=manage_socket,
144 name='SockThread',
145 args=((LOCALHOST, port),),
146 daemon=True,
147 ).start()
148
149 while True:
150 try:
151 if exit_now:
152 try:
153 exit()
154 except KeyboardInterrupt:
155 # exiting but got an extra KBI? Try again!
156 continue
157 try:
158 request = rpc.request_queue.get(block=True, timeout=0.05)
159 except queue.Empty:
160 request = None
161 # Issue 32207: calling handle_tk_events here adds spurious
162 # queue.Empty traceback to event handling exceptions.
163 if request:
164 seq, (method, args, kwargs) = request
165 ret = method(*args, **kwargs)
166 rpc.response_queue.put((seq, ret))
167 else:

Callers 15

autocomplete_w.pyFile · 0.70
config.pyFile · 0.70
codecontext.pyFile · 0.70
run.pyFile · 0.70
statusbar.pyFile · 0.70
debugger.pyFile · 0.70
calltip_w.pyFile · 0.70
pathbrowser.pyFile · 0.70
pyparse.pyFile · 0.70
configdialog.pyFile · 0.70
hyperparser.pyFile · 0.70
rpc.pyFile · 0.70

Calls 10

exitFunction · 0.85
methodFunction · 0.85
handle_tk_eventsFunction · 0.85
print_exceptionMethod · 0.80
capture_warningsFunction · 0.70
print_exceptionFunction · 0.70
printFunction · 0.50
startMethod · 0.45
getMethod · 0.45
putMethod · 0.45

Tested by

no test coverage detected