@@ -67,11 +67,12 @@ def in_pending_state(method: F) -> F:
67
67
@functools .wraps (method )
68
68
async def wrapper (self , * args , ** kwargs ):
69
69
# Create a future for the decorated method
70
- try :
71
- self ._ready = Future ()
72
- except RuntimeError :
73
- # No event loop running, use concurrent future
74
- self ._ready = CFuture ()
70
+ if self ._attempted_start :
71
+ try :
72
+ self ._ready = Future ()
73
+ except RuntimeError :
74
+ # No event loop running, use concurrent future
75
+ self ._ready = CFuture ()
75
76
try :
76
77
# call wrapped method, await, and set the result or exception.
77
78
out = await method (self , * args , ** kwargs )
@@ -119,6 +120,7 @@ def _emit(self, *, action: str) -> None:
119
120
def __init__ (self , * args , ** kwargs ):
120
121
super ().__init__ (** kwargs )
121
122
self ._shutdown_status = _ShutdownStatus .Unset
123
+ self ._attempted_start = False
122
124
# Create a place holder future.
123
125
try :
124
126
asyncio .get_running_loop ()
@@ -408,6 +410,7 @@ async def _async_start_kernel(self, **kw: t.Any) -> None:
408
410
keyword arguments that are passed down to build the kernel_cmd
409
411
and launching the kernel (e.g. Popen kwargs).
410
412
"""
413
+ self ._attempted_start = True
411
414
kernel_cmd , kw = await self ._async_pre_start_kernel (** kw )
412
415
413
416
# launch the kernel subprocess
0 commit comments