File tree Expand file tree Collapse file tree 2 files changed +14
-6
lines changed
Expand file tree Collapse file tree 2 files changed +14
-6
lines changed Original file line number Diff line number Diff line change @@ -51,10 +51,15 @@ class CodeBox(BaseBox):
5151 """
5252
5353 def __new__ (cls , * args , ** kwargs ):
54- if settings .CODEBOX_API_KEY is None :
54+ if (
55+ settings .CODEBOX_API_KEY is None
56+ or settings .CODEBOX_API_KEY == "local"
57+ or kwargs .pop ("local" , False )
58+ ):
5559 from .localbox import LocalBox
5660
5761 return LocalBox (* args , ** kwargs )
62+
5863 return super ().__new__ (cls , * args , ** kwargs )
5964
6065 def __init__ (self , * args , ** kwargs ) -> None :
Original file line number Diff line number Diff line change 99import json
1010import os
1111import subprocess
12+ import sys
1213import time
1314from asyncio .subprocess import Process
15+ from pathlib import Path
1416from typing import List , Optional , Union
1517from uuid import uuid4
1618
@@ -67,8 +69,11 @@ def start(self) -> CodeBoxStatus:
6769 else :
6870 out = subprocess .PIPE
6971 try :
72+ python = Path (sys .executable ).absolute ()
7073 self .jupyter = subprocess .Popen (
7174 [
75+ python ,
76+ "-m" ,
7277 "jupyter" ,
7378 "kernelgateway" ,
7479 "--KernelGatewayApp.ip='0.0.0.0'" ,
@@ -127,7 +132,10 @@ async def astart(self) -> CodeBoxStatus:
127132 out = None
128133 else :
129134 out = asyncio .subprocess .PIPE
135+ python = Path (sys .executable ).absolute ()
130136 self .jupyter = await asyncio .create_subprocess_exec (
137+ python ,
138+ "-m" ,
131139 "jupyter" ,
132140 "kernelgateway" ,
133141 "--KernelGatewayApp.ip='0.0.0.0'" ,
@@ -307,11 +315,6 @@ def run(
307315 print ("Error:\n " , error )
308316 return CodeBoxOutput (type = "error" , content = error )
309317
310- return CodeBoxOutput (
311- type = "error" ,
312- content = "Unknown message" ,
313- )
314-
315318 async def arun (
316319 self ,
317320 code : str ,
You can’t perform that action at this time.
0 commit comments