File tree 2 files changed +31
-0
lines changed
2 files changed +31
-0
lines changed Original file line number Diff line number Diff line change
1
+ #!/usr/bin/env python
2
+ """
3
+ For testing: test to make sure that everything still works when gevent monkey
4
+ patches are applied.
5
+ """
6
+ from __future__ import unicode_literals
7
+ from gevent .monkey import patch_all
8
+ from prompt_toolkit .shortcuts import prompt , create_eventloop
9
+
10
+
11
+ if __name__ == '__main__' :
12
+ # Apply patches.
13
+ patch_all ()
14
+
15
+ # There were some issues in the past when the event loop had an input hook.
16
+ def dummy_inputhook (* a ):
17
+ pass
18
+ eventloop = create_eventloop (inputhook = dummy_inputhook )
19
+
20
+ # Ask for input.
21
+ answer = prompt ('Give me some input: ' , eventloop = eventloop )
22
+ print ('You said: %s' % answer )
Original file line number Diff line number Diff line change 24
24
"""
25
25
from __future__ import unicode_literals
26
26
import os
27
+ import select
27
28
import threading
28
29
29
30
__all__ = (
@@ -73,6 +74,14 @@ def thread():
73
74
74
75
# Flush the read end of the pipe.
75
76
try :
77
+ # Before calling 'os.read', call select.select. This fixes a bug
78
+ # with Gevent where the following read call blocked the select call
79
+ # from the eventloop that we call through 'input_is_ready_func' in
80
+ # the above thread.
81
+ # This appears to be only required when gevent.monkey.patch_all()
82
+ # has been executed. Otherwise it doesn't do much.
83
+ select .select ([self ._r ], [], [])
84
+
76
85
os .read (self ._r , 1024 )
77
86
except OSError :
78
87
# This happens when the window resizes and a SIGWINCH was received.
You can’t perform that action at this time.
0 commit comments