MCPcopy Index your code
hub / github.com/python/cpython / handle1

Method handle1

Lib/_pyrepl/reader.py:708–749  ·  view source on GitHub ↗

Handle a single event. Wait as long as it takes if block is true (the default), otherwise return False if no event is pending.

(self, block: bool = True)

Source from the content-addressed store, hash-verified

706 pass
707
708 def handle1(self, block: bool = True) -> bool:
709 """Handle a single event. Wait as long as it takes if block
710 is true (the default), otherwise return False if no event is
711 pending."""
712
713 if self.msg:
714 self.msg = ""
715 self.dirty = True
716
717 while True:
718 # We use the same timeout as in readline.c: 100ms
719 self.run_hooks()
720 self.console.wait(100)
721 event = self.console.get_event(block=False)
722 if not event:
723 if block:
724 continue
725 return False
726
727 translate = True
728
729 if event.evt == "key":
730 self.input_trans.push(event)
731 elif event.evt == "scroll":
732 self.refresh()
733 elif event.evt == "resize":
734 self.refresh()
735 else:
736 translate = False
737
738 if translate:
739 cmd = self.input_trans.get()
740 else:
741 cmd = [event.evt, event.data]
742
743 if cmd is None:
744 if block:
745 continue
746 return False
747
748 self.do_cmd(cmd)
749 return True
750
751 def push_char(self, char: int | bytes) -> None:
752 self.console.push_char(char)

Callers 5

push_charMethod · 0.95
readlineMethod · 0.95
handle_all_eventsFunction · 0.80

Calls 7

run_hooksMethod · 0.95
refreshMethod · 0.95
do_cmdMethod · 0.95
waitMethod · 0.45
get_eventMethod · 0.45
pushMethod · 0.45
getMethod · 0.45