|
1 <!DOCTYPE html> |
|
2 <html><head> |
|
3 <title>eric6.Utilities.BackgroundService</title> |
|
4 <meta charset="UTF-8"> |
|
5 <style> |
|
6 body { |
|
7 background: #EDECE6; |
|
8 margin: 0em 1em 10em 1em; |
|
9 color: black; |
|
10 } |
|
11 |
|
12 h1 { color: white; background: #85774A; } |
|
13 h2 { color: white; background: #85774A; } |
|
14 h3 { color: white; background: #9D936E; } |
|
15 h4 { color: white; background: #9D936E; } |
|
16 |
|
17 a { color: #BA6D36; } |
|
18 |
|
19 </style> |
|
20 </head> |
|
21 <body><a NAME="top" ID="top"></a> |
|
22 <h1>eric6.Utilities.BackgroundService</h1> |
|
23 <p> |
|
24 Module implementing a background service for the various checkers and other |
|
25 python interpreter dependent functions. |
|
26 </p> |
|
27 <h3>Global Attributes</h3> |
|
28 <table> |
|
29 <tr><td>None</td></tr> |
|
30 </table> |
|
31 <h3>Classes</h3> |
|
32 <table> |
|
33 <tr> |
|
34 <td><a href="#BackgroundService">BackgroundService</a></td> |
|
35 <td>Class implementing the main part of the background service.</td> |
|
36 </tr> |
|
37 </table> |
|
38 <h3>Functions</h3> |
|
39 <table> |
|
40 <tr><td>None</td></tr> |
|
41 </table> |
|
42 <hr /><hr /> |
|
43 <a NAME="BackgroundService" ID="BackgroundService"></a> |
|
44 <h2>BackgroundService</h2> |
|
45 <p> |
|
46 Class implementing the main part of the background service. |
|
47 </p> |
|
48 <h3>Derived from</h3> |
|
49 QTcpServer |
|
50 <h3>Class Attributes</h3> |
|
51 <table> |
|
52 <tr><td>None</td></tr> |
|
53 </table> |
|
54 <h3>Class Methods</h3> |
|
55 <table> |
|
56 <tr><td>None</td></tr> |
|
57 </table> |
|
58 <h3>Methods</h3> |
|
59 <table> |
|
60 <tr> |
|
61 <td><a href="#BackgroundService.__init__">BackgroundService</a></td> |
|
62 <td>Constructor of the BackgroundService class.</td> |
|
63 </tr><tr> |
|
64 <td><a href="#BackgroundService.__processQueue">__processQueue</a></td> |
|
65 <td>Private method to take the next service request and send it to the client.</td> |
|
66 </tr><tr> |
|
67 <td><a href="#BackgroundService.__receive">__receive</a></td> |
|
68 <td>Private method to receive the response from the clients.</td> |
|
69 </tr><tr> |
|
70 <td><a href="#BackgroundService.__send">__send</a></td> |
|
71 <td>Private method to send a job request to one of the clients.</td> |
|
72 </tr><tr> |
|
73 <td><a href="#BackgroundService.__startExternalClient">__startExternalClient</a></td> |
|
74 <td>Private method to start the background client as external process.</td> |
|
75 </tr><tr> |
|
76 <td><a href="#BackgroundService.enqueueRequest">enqueueRequest</a></td> |
|
77 <td>Public method implementing a queued processing of incomming events.</td> |
|
78 </tr><tr> |
|
79 <td><a href="#BackgroundService.on_disconnectSocket">on_disconnectSocket</a></td> |
|
80 <td>Private slot called when connection to a client is lost.</td> |
|
81 </tr><tr> |
|
82 <td><a href="#BackgroundService.on_newConnection">on_newConnection</a></td> |
|
83 <td>Private slot for new incomming connections from the clients.</td> |
|
84 </tr><tr> |
|
85 <td><a href="#BackgroundService.preferencesOrProjectChanged">preferencesOrProjectChanged</a></td> |
|
86 <td>Public slot to restart the built in languages.</td> |
|
87 </tr><tr> |
|
88 <td><a href="#BackgroundService.restartService">restartService</a></td> |
|
89 <td>Public method to restart a given lanuage.</td> |
|
90 </tr><tr> |
|
91 <td><a href="#BackgroundService.serviceConnect">serviceConnect</a></td> |
|
92 <td>Public method to announce a new service to the background service/client.</td> |
|
93 </tr><tr> |
|
94 <td><a href="#BackgroundService.serviceDisconnect">serviceDisconnect</a></td> |
|
95 <td>Public method to remove the service from the service list.</td> |
|
96 </tr><tr> |
|
97 <td><a href="#BackgroundService.shutdown">shutdown</a></td> |
|
98 <td>Public method to cleanup the connections and processes when eric is shuting down.</td> |
|
99 </tr> |
|
100 </table> |
|
101 <h3>Static Methods</h3> |
|
102 <table> |
|
103 <tr><td>None</td></tr> |
|
104 </table> |
|
105 <a NAME="BackgroundService.__init__" ID="BackgroundService.__init__"></a> |
|
106 <h4>BackgroundService (Constructor)</h4> |
|
107 <b>BackgroundService</b>(<i></i>) |
|
108 <p> |
|
109 Constructor of the BackgroundService class. |
|
110 </p><a NAME="BackgroundService.__processQueue" ID="BackgroundService.__processQueue"></a> |
|
111 <h4>BackgroundService.__processQueue</h4> |
|
112 <b>__processQueue</b>(<i></i>) |
|
113 <p> |
|
114 Private method to take the next service request and send it to the |
|
115 client. |
|
116 </p><a NAME="BackgroundService.__receive" ID="BackgroundService.__receive"></a> |
|
117 <h4>BackgroundService.__receive</h4> |
|
118 <b>__receive</b>(<i>lang</i>) |
|
119 <p> |
|
120 Private method to receive the response from the clients. |
|
121 </p><dl> |
|
122 <dt><i>lang</i></dt> |
|
123 <dd> |
|
124 language of the incomming connection (str) |
|
125 </dd> |
|
126 </dl><a NAME="BackgroundService.__send" ID="BackgroundService.__send"></a> |
|
127 <h4>BackgroundService.__send</h4> |
|
128 <b>__send</b>(<i>fx, lang, fn, data</i>) |
|
129 <p> |
|
130 Private method to send a job request to one of the clients. |
|
131 </p><dl> |
|
132 <dt><i>fx</i></dt> |
|
133 <dd> |
|
134 remote function name to execute (str) |
|
135 </dd><dt><i>lang</i></dt> |
|
136 <dd> |
|
137 language to connect to (str) |
|
138 </dd><dt><i>fn</i></dt> |
|
139 <dd> |
|
140 filename for identification (str) |
|
141 </dd><dt><i>data</i></dt> |
|
142 <dd> |
|
143 function argument(s) (any basic datatype) |
|
144 </dd> |
|
145 </dl><a NAME="BackgroundService.__startExternalClient" ID="BackgroundService.__startExternalClient"></a> |
|
146 <h4>BackgroundService.__startExternalClient</h4> |
|
147 <b>__startExternalClient</b>(<i>interpreter, port</i>) |
|
148 <p> |
|
149 Private method to start the background client as external process. |
|
150 </p><dl> |
|
151 <dt><i>interpreter</i></dt> |
|
152 <dd> |
|
153 path and name of the executable to start (string) |
|
154 </dd><dt><i>port</i></dt> |
|
155 <dd> |
|
156 socket port to which the interpreter should connect (int) |
|
157 </dd> |
|
158 </dl><dl> |
|
159 <dt>Returns:</dt> |
|
160 <dd> |
|
161 the process object (QProcess or None) |
|
162 </dd> |
|
163 </dl><a NAME="BackgroundService.enqueueRequest" ID="BackgroundService.enqueueRequest"></a> |
|
164 <h4>BackgroundService.enqueueRequest</h4> |
|
165 <b>enqueueRequest</b>(<i>fx, lang, fn, data</i>) |
|
166 <p> |
|
167 Public method implementing a queued processing of incomming events. |
|
168 </p><p> |
|
169 Dublicate service requests updates an older request to avoid overrun or |
|
170 starving of the services. |
|
171 </p><dl> |
|
172 <dt><i>fx</i></dt> |
|
173 <dd> |
|
174 function name of the service (str) |
|
175 </dd><dt><i>lang</i></dt> |
|
176 <dd> |
|
177 language to connect to (str) |
|
178 </dd><dt><i>fn</i></dt> |
|
179 <dd> |
|
180 filename for identification (str) |
|
181 </dd><dt><i>data</i></dt> |
|
182 <dd> |
|
183 function argument(s) (any basic datatype(s)) |
|
184 </dd> |
|
185 </dl><a NAME="BackgroundService.on_disconnectSocket" ID="BackgroundService.on_disconnectSocket"></a> |
|
186 <h4>BackgroundService.on_disconnectSocket</h4> |
|
187 <b>on_disconnectSocket</b>(<i>lang</i>) |
|
188 <p> |
|
189 Private slot called when connection to a client is lost. |
|
190 </p><dl> |
|
191 <dt><i>lang</i></dt> |
|
192 <dd> |
|
193 client language which connection is lost (str) |
|
194 </dd> |
|
195 </dl><a NAME="BackgroundService.on_newConnection" ID="BackgroundService.on_newConnection"></a> |
|
196 <h4>BackgroundService.on_newConnection</h4> |
|
197 <b>on_newConnection</b>(<i></i>) |
|
198 <p> |
|
199 Private slot for new incomming connections from the clients. |
|
200 </p><a NAME="BackgroundService.preferencesOrProjectChanged" ID="BackgroundService.preferencesOrProjectChanged"></a> |
|
201 <h4>BackgroundService.preferencesOrProjectChanged</h4> |
|
202 <b>preferencesOrProjectChanged</b>(<i></i>) |
|
203 <p> |
|
204 Public slot to restart the built in languages. |
|
205 </p><a NAME="BackgroundService.restartService" ID="BackgroundService.restartService"></a> |
|
206 <h4>BackgroundService.restartService</h4> |
|
207 <b>restartService</b>(<i>language, forceKill=False</i>) |
|
208 <p> |
|
209 Public method to restart a given lanuage. |
|
210 </p><dl> |
|
211 <dt><i>language</i></dt> |
|
212 <dd> |
|
213 to restart (str) |
|
214 </dd><dt><i>forceKill=</i></dt> |
|
215 <dd> |
|
216 flag to kill a running task (bool) |
|
217 </dd> |
|
218 </dl><a NAME="BackgroundService.serviceConnect" ID="BackgroundService.serviceConnect"></a> |
|
219 <h4>BackgroundService.serviceConnect</h4> |
|
220 <b>serviceConnect</b>(<i>fx, lang, modulepath, module, callback, onErrorCallback=None</i>) |
|
221 <p> |
|
222 Public method to announce a new service to the background |
|
223 service/client. |
|
224 </p><dl> |
|
225 <dt><i>fx</i></dt> |
|
226 <dd> |
|
227 function name of the service (str) |
|
228 </dd><dt><i>lang</i></dt> |
|
229 <dd> |
|
230 language of the new service (str) |
|
231 </dd><dt><i>modulepath</i></dt> |
|
232 <dd> |
|
233 full path to the module (str) |
|
234 </dd><dt><i>module</i></dt> |
|
235 <dd> |
|
236 name to import (str) |
|
237 </dd><dt><i>callback</i></dt> |
|
238 <dd> |
|
239 function on service response (function) |
|
240 </dd><dt><i>onErrorCallback</i></dt> |
|
241 <dd> |
|
242 function if client isn't available (function) |
|
243 </dd> |
|
244 </dl><a NAME="BackgroundService.serviceDisconnect" ID="BackgroundService.serviceDisconnect"></a> |
|
245 <h4>BackgroundService.serviceDisconnect</h4> |
|
246 <b>serviceDisconnect</b>(<i>fx, lang</i>) |
|
247 <p> |
|
248 Public method to remove the service from the service list. |
|
249 </p><dl> |
|
250 <dt><i>fx</i></dt> |
|
251 <dd> |
|
252 function name of the service (function) |
|
253 </dd><dt><i>lang</i></dt> |
|
254 <dd> |
|
255 language of the service (str) |
|
256 </dd> |
|
257 </dl><a NAME="BackgroundService.shutdown" ID="BackgroundService.shutdown"></a> |
|
258 <h4>BackgroundService.shutdown</h4> |
|
259 <b>shutdown</b>(<i></i>) |
|
260 <p> |
|
261 Public method to cleanup the connections and processes when eric is |
|
262 shuting down. |
|
263 </p> |
|
264 <div align="right"><a href="#top">Up</a></div> |
|
265 <hr /> |
|
266 </body></html> |