|
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><h3>Signals</h3> |
|
48 <dl> |
|
49 <dt>batchJobDone(function, language)</dt> |
|
50 <dd> |
|
51 emitted to indicate the end of |
|
52 a batch job (str, str) |
|
53 </dd><dt>serviceNotAvailable(function, language, filename, message)</dt> |
|
54 <dd> |
|
55 emitted to indicate the non-availability of a service function |
|
56 (str, str, str, str) |
|
57 </dd> |
|
58 </dl> |
|
59 <h3>Derived from</h3> |
|
60 QTcpServer |
|
61 <h3>Class Attributes</h3> |
|
62 <table> |
|
63 <tr><td>None</td></tr> |
|
64 </table> |
|
65 <h3>Class Methods</h3> |
|
66 <table> |
|
67 <tr><td>None</td></tr> |
|
68 </table> |
|
69 <h3>Methods</h3> |
|
70 <table> |
|
71 <tr> |
|
72 <td><a href="#BackgroundService.__init__">BackgroundService</a></td> |
|
73 <td>Constructor of the BackgroundService class.</td> |
|
74 </tr><tr> |
|
75 <td><a href="#BackgroundService.__processQueue">__processQueue</a></td> |
|
76 <td>Private method to take the next service request and send it to the client.</td> |
|
77 </tr><tr> |
|
78 <td><a href="#BackgroundService.__receive">__receive</a></td> |
|
79 <td>Private method to receive the response from the clients.</td> |
|
80 </tr><tr> |
|
81 <td><a href="#BackgroundService.__send">__send</a></td> |
|
82 <td>Private method to send a job request to one of the clients.</td> |
|
83 </tr><tr> |
|
84 <td><a href="#BackgroundService.__startExternalClient">__startExternalClient</a></td> |
|
85 <td>Private method to start the background client as external process.</td> |
|
86 </tr><tr> |
|
87 <td><a href="#BackgroundService.enqueueRequest">enqueueRequest</a></td> |
|
88 <td>Public method implementing a queued processing of incomming events.</td> |
|
89 </tr><tr> |
|
90 <td><a href="#BackgroundService.on_disconnectSocket">on_disconnectSocket</a></td> |
|
91 <td>Private slot called when connection to a client is lost.</td> |
|
92 </tr><tr> |
|
93 <td><a href="#BackgroundService.on_newConnection">on_newConnection</a></td> |
|
94 <td>Private slot for new incomming connections from the clients.</td> |
|
95 </tr><tr> |
|
96 <td><a href="#BackgroundService.preferencesOrProjectChanged">preferencesOrProjectChanged</a></td> |
|
97 <td>Public slot to restart the built in languages.</td> |
|
98 </tr><tr> |
|
99 <td><a href="#BackgroundService.requestCancel">requestCancel</a></td> |
|
100 <td>Public method to ask a batch job to terminate.</td> |
|
101 </tr><tr> |
|
102 <td><a href="#BackgroundService.restartService">restartService</a></td> |
|
103 <td>Public method to restart a given lanuage.</td> |
|
104 </tr><tr> |
|
105 <td><a href="#BackgroundService.serviceConnect">serviceConnect</a></td> |
|
106 <td>Public method to announce a new service to the background service/client.</td> |
|
107 </tr><tr> |
|
108 <td><a href="#BackgroundService.serviceDisconnect">serviceDisconnect</a></td> |
|
109 <td>Public method to remove the service from the service list.</td> |
|
110 </tr><tr> |
|
111 <td><a href="#BackgroundService.shutdown">shutdown</a></td> |
|
112 <td>Public method to cleanup the connections and processes when eric is shutting down.</td> |
|
113 </tr> |
|
114 </table> |
|
115 <h3>Static Methods</h3> |
|
116 <table> |
|
117 <tr><td>None</td></tr> |
|
118 </table> |
|
119 <a NAME="BackgroundService.__init__" ID="BackgroundService.__init__"></a> |
|
120 <h4>BackgroundService (Constructor)</h4> |
|
121 <b>BackgroundService</b>(<i></i>) |
|
122 <p> |
|
123 Constructor of the BackgroundService class. |
|
124 </p><a NAME="BackgroundService.__processQueue" ID="BackgroundService.__processQueue"></a> |
|
125 <h4>BackgroundService.__processQueue</h4> |
|
126 <b>__processQueue</b>(<i></i>) |
|
127 <p> |
|
128 Private method to take the next service request and send it to the |
|
129 client. |
|
130 </p><a NAME="BackgroundService.__receive" ID="BackgroundService.__receive"></a> |
|
131 <h4>BackgroundService.__receive</h4> |
|
132 <b>__receive</b>(<i>lang</i>) |
|
133 <p> |
|
134 Private method to receive the response from the clients. |
|
135 </p><dl> |
|
136 <dt><i>lang</i></dt> |
|
137 <dd> |
|
138 language of the incomming connection (str) |
|
139 </dd> |
|
140 </dl><a NAME="BackgroundService.__send" ID="BackgroundService.__send"></a> |
|
141 <h4>BackgroundService.__send</h4> |
|
142 <b>__send</b>(<i>fx, lang, fn, data</i>) |
|
143 <p> |
|
144 Private method to send a job request to one of the clients. |
|
145 </p><dl> |
|
146 <dt><i>fx</i></dt> |
|
147 <dd> |
|
148 remote function name to execute (str) |
|
149 </dd><dt><i>lang</i></dt> |
|
150 <dd> |
|
151 language to connect to (str) |
|
152 </dd><dt><i>fn</i></dt> |
|
153 <dd> |
|
154 filename for identification (str) |
|
155 </dd><dt><i>data</i></dt> |
|
156 <dd> |
|
157 function argument(s) (any basic datatype) |
|
158 </dd> |
|
159 </dl><a NAME="BackgroundService.__startExternalClient" ID="BackgroundService.__startExternalClient"></a> |
|
160 <h4>BackgroundService.__startExternalClient</h4> |
|
161 <b>__startExternalClient</b>(<i>interpreter, port</i>) |
|
162 <p> |
|
163 Private method to start the background client as external process. |
|
164 </p><dl> |
|
165 <dt><i>interpreter</i></dt> |
|
166 <dd> |
|
167 path and name of the executable to start (string) |
|
168 </dd><dt><i>port</i></dt> |
|
169 <dd> |
|
170 socket port to which the interpreter should connect (int) |
|
171 </dd> |
|
172 </dl><dl> |
|
173 <dt>Returns:</dt> |
|
174 <dd> |
|
175 the process object (QProcess or None) |
|
176 </dd> |
|
177 </dl><a NAME="BackgroundService.enqueueRequest" ID="BackgroundService.enqueueRequest"></a> |
|
178 <h4>BackgroundService.enqueueRequest</h4> |
|
179 <b>enqueueRequest</b>(<i>fx, lang, fn, data</i>) |
|
180 <p> |
|
181 Public method implementing a queued processing of incomming events. |
|
182 </p><p> |
|
183 Dublicate service requests updates an older request to avoid overrun or |
|
184 starving of the services. |
|
185 </p><dl> |
|
186 <dt><i>fx</i></dt> |
|
187 <dd> |
|
188 function name of the service (str) |
|
189 </dd><dt><i>lang</i></dt> |
|
190 <dd> |
|
191 language to connect to (str) |
|
192 </dd><dt><i>fn</i></dt> |
|
193 <dd> |
|
194 filename for identification (str) |
|
195 </dd><dt><i>data</i></dt> |
|
196 <dd> |
|
197 function argument(s) (any basic datatype(s)) |
|
198 </dd> |
|
199 </dl><a NAME="BackgroundService.on_disconnectSocket" ID="BackgroundService.on_disconnectSocket"></a> |
|
200 <h4>BackgroundService.on_disconnectSocket</h4> |
|
201 <b>on_disconnectSocket</b>(<i>lang</i>) |
|
202 <p> |
|
203 Private slot called when connection to a client is lost. |
|
204 </p><dl> |
|
205 <dt><i>lang</i></dt> |
|
206 <dd> |
|
207 client language which connection is lost (str) |
|
208 </dd> |
|
209 </dl><a NAME="BackgroundService.on_newConnection" ID="BackgroundService.on_newConnection"></a> |
|
210 <h4>BackgroundService.on_newConnection</h4> |
|
211 <b>on_newConnection</b>(<i></i>) |
|
212 <p> |
|
213 Private slot for new incomming connections from the clients. |
|
214 </p><a NAME="BackgroundService.preferencesOrProjectChanged" ID="BackgroundService.preferencesOrProjectChanged"></a> |
|
215 <h4>BackgroundService.preferencesOrProjectChanged</h4> |
|
216 <b>preferencesOrProjectChanged</b>(<i></i>) |
|
217 <p> |
|
218 Public slot to restart the built in languages. |
|
219 </p><a NAME="BackgroundService.requestCancel" ID="BackgroundService.requestCancel"></a> |
|
220 <h4>BackgroundService.requestCancel</h4> |
|
221 <b>requestCancel</b>(<i>fx, lang</i>) |
|
222 <p> |
|
223 Public method to ask a batch job to terminate. |
|
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 to connect to (str) |
|
231 </dd> |
|
232 </dl><a NAME="BackgroundService.restartService" ID="BackgroundService.restartService"></a> |
|
233 <h4>BackgroundService.restartService</h4> |
|
234 <b>restartService</b>(<i>language, forceKill=False</i>) |
|
235 <p> |
|
236 Public method to restart a given lanuage. |
|
237 </p><dl> |
|
238 <dt><i>language</i></dt> |
|
239 <dd> |
|
240 to restart (str) |
|
241 </dd><dt><i>forceKill=</i></dt> |
|
242 <dd> |
|
243 flag to kill a running task (bool) |
|
244 </dd> |
|
245 </dl><a NAME="BackgroundService.serviceConnect" ID="BackgroundService.serviceConnect"></a> |
|
246 <h4>BackgroundService.serviceConnect</h4> |
|
247 <b>serviceConnect</b>(<i>fx, lang, modulepath, module, callback, onErrorCallback=None, onBatchDone=None</i>) |
|
248 <p> |
|
249 Public method to announce a new service to the background |
|
250 service/client. |
|
251 </p><dl> |
|
252 <dt><i>fx</i></dt> |
|
253 <dd> |
|
254 function name of the service (str) |
|
255 </dd><dt><i>lang</i></dt> |
|
256 <dd> |
|
257 language of the new service (str) |
|
258 </dd><dt><i>modulepath</i></dt> |
|
259 <dd> |
|
260 full path to the module (str) |
|
261 </dd><dt><i>module</i></dt> |
|
262 <dd> |
|
263 name to import (str) |
|
264 </dd><dt><i>callback</i></dt> |
|
265 <dd> |
|
266 function called on service response (function) |
|
267 </dd><dt><i>onErrorCallback</i></dt> |
|
268 <dd> |
|
269 function called, if client isn't available |
|
270 (function) |
|
271 </dd><dt><i>onBatchDone</i></dt> |
|
272 <dd> |
|
273 function called when a batch job is done (function) |
|
274 </dd> |
|
275 </dl><a NAME="BackgroundService.serviceDisconnect" ID="BackgroundService.serviceDisconnect"></a> |
|
276 <h4>BackgroundService.serviceDisconnect</h4> |
|
277 <b>serviceDisconnect</b>(<i>fx, lang</i>) |
|
278 <p> |
|
279 Public method to remove the service from the service list. |
|
280 </p><dl> |
|
281 <dt><i>fx</i></dt> |
|
282 <dd> |
|
283 function name of the service (function) |
|
284 </dd><dt><i>lang</i></dt> |
|
285 <dd> |
|
286 language of the service (str) |
|
287 </dd> |
|
288 </dl><a NAME="BackgroundService.shutdown" ID="BackgroundService.shutdown"></a> |
|
289 <h4>BackgroundService.shutdown</h4> |
|
290 <b>shutdown</b>(<i></i>) |
|
291 <p> |
|
292 Public method to cleanup the connections and processes when eric is |
|
293 shutting down. |
|
294 </p> |
|
295 <div align="right"><a href="#top">Up</a></div> |
|
296 <hr /> |
|
297 </body></html> |