Skip to content

Commit 73e1ecc

Browse files
committed
renamed receive_nb() to receive_nowait() clarified usage
receive_nowait() raises gevent.empty.Queue
1 parent e62b310 commit 73e1ecc

File tree

3 files changed

+16
-11
lines changed

3 files changed

+16
-11
lines changed

README.rst

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,13 @@ Automatically performs WebSocket handshake and passes a ``GeventWebSocketClient`
138138
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
139139
WebSocket client abstraction with fully non-blocking methods.
140140

141+
receive() and receive_nowait() differs in that receive_nowait()
142+
will raise a ``gevent.queue.Empty`` exception immediately
143+
if there is no message available.
144+
141145
``receive()``
142146

143-
``receive_nb()``
147+
``receive_nowait()``
144148

145149
``send(msg)``
146150

flask_uwsgi_websocket/_gevent.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,20 +29,21 @@ def send(self, message):
2929
self.send_event.set()
3030

3131
def receive(self):
32-
""" Receives a message from the websocket (blocking).
32+
""" Receives a message from the websocket.
33+
Although the underlying bytes are received via non blocking i/o,
34+
this method will block if there are no waiting messages.
3335
:return the message
3436
"""
3537
return self.recv_queue.get()
3638

37-
def receive_nb(self):
38-
""" Receives a message from the websocket (non-blocking).
39-
:return the message or None if no message was available
40-
immediately
39+
def receive_nowait(self):
40+
""" Receives a message from the websocket.
41+
This differs from the receive() method in that, if there are
42+
no waiting messages, this method will quickly return.
43+
:return the messag
44+
:raise gevent.queue.Empty if no message was immediately available
4145
"""
42-
try:
43-
return self.recv_queue.get_nowait()
44-
except Empty:
45-
return None
46+
return self.recv_queue.get_nowait()
4647

4748
def close(self):
4849
self.connected = False

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
setup(
55
name='Flask-uWSGI-WebSocket',
6-
version='0.2.5.2',
6+
version='0.2.5.3',
77
url='https://github.com/zeekay/flask-uwsgi-websocket',
88
license='MIT',
99
author='Zach Kelling',

0 commit comments

Comments
 (0)