2222from jupyter_client .client import KernelClient
2323from .channels import ZMQSocketChannel
2424
25- try :
26- monotonic = time .monotonic
27- except AttributeError :
28- # py2
29- monotonic = time .time # close enough
30-
31- try :
32- TimeoutError
33- except NameError :
34- # py2
35- TimeoutError = RuntimeError
36-
3725
3826def reqrep (meth , channel = 'shell' ):
3927 def wrapped (self , * args , ** kwargs ):
@@ -177,10 +165,10 @@ async def wait_for_ready(self, timeout=None):
177165 async def _recv_reply (self , msg_id , timeout = None , channel = 'shell' ):
178166 """Receive and return the reply for a given request"""
179167 if timeout is not None :
180- deadline = monotonic () + timeout
168+ deadline = time . monotonic () + timeout
181169 while True :
182170 if timeout is not None :
183- timeout = max (0 , deadline - monotonic ())
171+ timeout = max (0 , deadline - time . monotonic ())
184172 try :
185173 if channel == 'control' :
186174 reply = await self .get_control_msg (timeout = timeout )
@@ -211,8 +199,6 @@ def _stdin_hook_default(self, msg):
211199 content = msg ['content' ]
212200 if content .get ('password' , False ):
213201 prompt = getpass
214- elif sys .version_info < (3 ,):
215- prompt = raw_input
216202 else :
217203 prompt = input
218204
@@ -265,8 +251,6 @@ async def execute_interactive(self, code, silent=False, store_history=True,
265251 You can pass a custom output_hook callable that will be called
266252 with every IOPub message that is produced instead of the default redisplay.
267253
268- .. versionadded:: 5.0
269-
270254 Parameters
271255 ----------
272256 code : str
@@ -345,7 +329,7 @@ async def execute_interactive(self, code, silent=False, store_history=True,
345329
346330 # set deadline based on timeout
347331 if timeout is not None :
348- deadline = monotonic () + timeout
332+ deadline = time . monotonic () + timeout
349333 else :
350334 timeout_ms = None
351335
@@ -361,7 +345,7 @@ async def execute_interactive(self, code, silent=False, store_history=True,
361345 # wait for output and redisplay it
362346 while True :
363347 if timeout is not None :
364- timeout = max (0 , deadline - monotonic ())
348+ timeout = max (0 , deadline - time . monotonic ())
365349 timeout_ms = 1e3 * timeout
366350 events = dict (poller .poll (timeout_ms ))
367351 if not events :
@@ -387,5 +371,5 @@ async def execute_interactive(self, code, silent=False, store_history=True,
387371
388372 # output is done, get the reply
389373 if timeout is not None :
390- timeout = max (0 , deadline - monotonic ())
374+ timeout = max (0 , deadline - time . monotonic ())
391375 return await self ._recv_reply (msg_id , timeout = timeout )
0 commit comments