File tree Expand file tree Collapse file tree 2 files changed +22
-17
lines changed Expand file tree Collapse file tree 2 files changed +22
-17
lines changed Original file line number Diff line number Diff line change @@ -126,13 +126,13 @@ async def astart(self) -> CodeBoxStatus:
126
126
if settings .VERBOSE :
127
127
print (f"{ self } is already started!" )
128
128
return CodeBoxStatus (status = "started" )
129
- self .session_id = (
130
- await abase_request (
131
- self . aiohttp_session ,
132
- method = "GET" ,
133
- endpoint = "/codebox/start" ,
134
- )
135
- )[ "id" ]
129
+ self .session_id = UUID (
130
+ int = (
131
+ await abase_request (
132
+ self . aiohttp_session , method = "GET" , endpoint = "/codebox/start"
133
+ )
134
+ )[ "id" ]
135
+ )
136
136
if settings .VERBOSE :
137
137
print (f"{ self } started!" )
138
138
return CodeBoxStatus (status = "started" )
@@ -287,12 +287,14 @@ async def arestart(self) -> CodeBoxStatus:
287
287
)
288
288
289
289
def stop (self ) -> CodeBoxStatus :
290
- return CodeBoxStatus (
290
+ status = CodeBoxStatus (
291
291
** self .codebox_request (
292
292
method = "POST" ,
293
293
endpoint = "/stop" ,
294
294
)
295
295
)
296
+ self .session_id = None
297
+ return status
296
298
297
299
async def astop (self ) -> CodeBoxStatus :
298
300
status = CodeBoxStatus (
@@ -301,6 +303,7 @@ async def astop(self) -> CodeBoxStatus:
301
303
endpoint = "/stop" ,
302
304
)
303
305
)
306
+ self .session_id = None
304
307
if self .aiohttp_session :
305
308
await self .aiohttp_session .close ()
306
309
self .aiohttp_session = None
Original file line number Diff line number Diff line change @@ -506,15 +506,17 @@ async def arestart(self) -> CodeBoxStatus:
506
506
return CodeBoxStatus (status = "restarted" )
507
507
508
508
def stop (self ) -> CodeBoxStatus :
509
- for pid in self ._jupyter_pids :
510
- print (f"Killing { pid } " )
511
- os .kill (pid , signal .SIGTERM )
512
-
513
- if self .jupyter is not None :
514
- self .jupyter .terminate ()
515
- self .jupyter .wait ()
516
- self .jupyter = None
517
- time .sleep (2 )
509
+ try :
510
+ if self .jupyter is not None :
511
+ self .jupyter .terminate ()
512
+ self .jupyter .wait ()
513
+ self .jupyter = None
514
+ time .sleep (2 )
515
+ else :
516
+ for pid in self ._jupyter_pids :
517
+ os .kill (pid , signal .SIGTERM )
518
+ except ProcessLookupError :
519
+ pass
518
520
519
521
if self .ws is not None :
520
522
try :
You can’t perform that action at this time.
0 commit comments