22
22
from jupyter_client .client import KernelClient
23
23
from .channels import ZMQSocketChannel
24
24
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
-
37
25
38
26
def reqrep (meth , channel = 'shell' ):
39
27
def wrapped (self , * args , ** kwargs ):
@@ -177,10 +165,10 @@ async def wait_for_ready(self, timeout=None):
177
165
async def _recv_reply (self , msg_id , timeout = None , channel = 'shell' ):
178
166
"""Receive and return the reply for a given request"""
179
167
if timeout is not None :
180
- deadline = monotonic () + timeout
168
+ deadline = time . monotonic () + timeout
181
169
while True :
182
170
if timeout is not None :
183
- timeout = max (0 , deadline - monotonic ())
171
+ timeout = max (0 , deadline - time . monotonic ())
184
172
try :
185
173
if channel == 'control' :
186
174
reply = await self .get_control_msg (timeout = timeout )
@@ -211,8 +199,6 @@ def _stdin_hook_default(self, msg):
211
199
content = msg ['content' ]
212
200
if content .get ('password' , False ):
213
201
prompt = getpass
214
- elif sys .version_info < (3 ,):
215
- prompt = raw_input
216
202
else :
217
203
prompt = input
218
204
@@ -265,8 +251,6 @@ async def execute_interactive(self, code, silent=False, store_history=True,
265
251
You can pass a custom output_hook callable that will be called
266
252
with every IOPub message that is produced instead of the default redisplay.
267
253
268
- .. versionadded:: 5.0
269
-
270
254
Parameters
271
255
----------
272
256
code : str
@@ -345,7 +329,7 @@ async def execute_interactive(self, code, silent=False, store_history=True,
345
329
346
330
# set deadline based on timeout
347
331
if timeout is not None :
348
- deadline = monotonic () + timeout
332
+ deadline = time . monotonic () + timeout
349
333
else :
350
334
timeout_ms = None
351
335
@@ -361,7 +345,7 @@ async def execute_interactive(self, code, silent=False, store_history=True,
361
345
# wait for output and redisplay it
362
346
while True :
363
347
if timeout is not None :
364
- timeout = max (0 , deadline - monotonic ())
348
+ timeout = max (0 , deadline - time . monotonic ())
365
349
timeout_ms = 1e3 * timeout
366
350
events = dict (poller .poll (timeout_ms ))
367
351
if not events :
@@ -387,5 +371,5 @@ async def execute_interactive(self, code, silent=False, store_history=True,
387
371
388
372
# output is done, get the reply
389
373
if timeout is not None :
390
- timeout = max (0 , deadline - monotonic ())
374
+ timeout = max (0 , deadline - time . monotonic ())
391
375
return await self ._recv_reply (msg_id , timeout = timeout )
0 commit comments