3
3
#superclass : #Object ,
4
4
#instVars : [
5
5
' promiseHandler' ,
6
+ ' sendMessageHandler' ,
6
7
' processHandler'
7
8
],
8
9
#classInstVars : [
@@ -228,6 +229,15 @@ if __name__ == "__main__":
228
229
pharo_hooks_globals.logger.log("PYTHON: Finished command execution")'
229
230
]
230
231
232
+ { #category : #instructions }
233
+ PBApplication class >> resetUniqueInstance [
234
+ uniqueInstance ifNotNil: [
235
+ [ uniqueInstance stop ]
236
+ on: Error
237
+ do: [ UIManager inform: ' Error on reseting unique instance.' ]. ].
238
+ uniqueInstance := nil
239
+ ]
240
+
231
241
{ #category : #instructions }
232
242
PBApplication class >> retrieveExpression: obj [
233
243
self assert: self isRunning.
@@ -279,6 +289,21 @@ PBApplication class >> stop [
279
289
uniqueInstance := nil
280
290
]
281
291
292
+ { #category : #handlers }
293
+ PBApplication >> handlers [
294
+ ^ Array
295
+ with: promiseHandler
296
+ with: sendMessageHandler
297
+ with: processHandler
298
+ ]
299
+
300
+ { #category : #accessing }
301
+ PBApplication >> initializeHandlers [
302
+ processHandler := PBProcessHandler new .
303
+ promiseHandler := PBPromiseHandler new .
304
+ sendMessageHandler := PBSendMessageHandler new
305
+ ]
306
+
282
307
{ #category : #testing }
283
308
PBApplication >> isPythonReady [
284
309
" Ensures python webserver is ready for receiving commands"
@@ -287,21 +312,19 @@ PBApplication >> isPythonReady [
287
312
288
313
{ #category : #testing }
289
314
PBApplication >> isRunning [
290
- ^ processHandler isRunning and : [ promiseHandler isRunning ]
315
+ ^ self handlers allSatisfy: # isRunning
291
316
]
292
317
293
318
{ #category : #accessing }
294
319
PBApplication >> start [
295
- processHandler := PBProcessHandler new .
296
- processHandler start.
297
- promiseHandler := PBPromiseHandler new .
298
- promiseHandler start.
299
-
320
+ self initializeHandlers.
321
+ self handlers do: #start .
300
322
self waitInitialization.
301
323
]
302
324
303
325
{ #category : #accessing }
304
326
PBApplication >> stop [
327
+ self handlers do: #stop
305
328
]
306
329
307
330
{ #category : #' as yet unclassified' }
0 commit comments