Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Formal fixes (spacing, line lengths)

  • Loading branch information...
commit 707f365f8975934f9927275035282599377793c3 1 parent f0d6b2f
@rgalanakis authored
View
1  examples/futures.py
@@ -25,6 +25,7 @@
import goless
+
# First create the async versions built on promises
def inverse_async(future):
c = goless.chan()
View
3  examples/pipeline.py
@@ -14,7 +14,6 @@
from __future__ import print_function
import hashlib
-
import os
import goless
@@ -28,7 +27,7 @@ def pipeline():
def scanner():
for d, dn, f in os.walk('.'):
for fn in f:
- files.send(os.path.join(d,fn))
+ files.send(os.path.join(d, fn))
files.close()
def hasher():
View
4 examples/producer_consumer.py
@@ -17,7 +17,7 @@
def main():
done = goless.chan()
msgs = goless.chan()
- out = goless.chan()
+ out = goless.chan()
def produce():
for i in range(10):
@@ -26,7 +26,7 @@ def produce():
def consume(name):
for msg in msgs:
- out.send('%s:%s ' % (name,msg))
+ out.send('%s:%s ' % (name, msg))
def logger():
for msg in out:
View
1  goless/__init__.py
@@ -12,7 +12,6 @@
import logging
import sys
-
import traceback
from .backends import current as _be
View
1  goless/backends.py
@@ -173,6 +173,7 @@ def calculate_backend(name_from_env, backends=None):
raise RuntimeError(
'Invalid backend %r specified. Valid backends are: %s'
% (name_from_env, _default_backends.keys()))
+ # noinspection PyCallingNonCallable
return backends[name_from_env]()
try:
return _calc_default(backends)
View
18 goless/channels.py
@@ -43,7 +43,8 @@ def recv(self):
"""
Receive a value from the channel.
Receiving will always block if no value is available.
- If the channel is already closed, :class:`goless.ChannelClosed` will be raised.
+ If the channel is already closed,
+ :class:`goless.ChannelClosed` will be raised.
If the channel closes during a blocking ``recv``,
:class:`goless.ChannelClosed` will be raised. (#TODO)
"""
@@ -72,8 +73,10 @@ def send_ready(self):
def close(self):
"""
Closes the channel, not allowing further communication.
- Any blocking senders or receivers will be woken up and raise :class:`goless.ChannelClosed`.
- Receiving or sending to a closed channel will raise :class:`goless.ChannelClosed`.
+ Any blocking senders or receivers will be woken up and
+ raise :class:`goless.ChannelClosed`.
+ Receiving or sending to a closed channel
+ will raise :class:`goless.ChannelClosed`.
"""
self._closed = True
@@ -149,7 +152,11 @@ def recv_ready(self):
return self.values_deque or self.waiting_chan.balance > 0
def send_ready(self):
- return len(self.values_deque) < self.maxsize or self.waiting_chan.balance < 0
+ room_in_queue = len(self.values_deque) < self.maxsize
+ if room_in_queue:
+ return True
+ receivers_waiting = self.waiting_chan.balance < 0
+ return receivers_waiting
def close(self):
# This next yield gives a chance to all blocked receivers to return
@@ -161,7 +168,8 @@ def close(self):
# but still get a ChannelClosed error.
_be.yield_()
# To make sure all pending tasklets are woken up,
- # we mark the channel closed and then spam out sends or receives if needed.
+ # we mark the channel closed and then spam out sends or
+ # receives if needed.
# The tasklets will wake up, see the channel is closed,
# and raise a ChannelClosed error.
GoChannel.close(self)
View
3  goless/selecting.py
@@ -18,7 +18,8 @@ def exec_(self):
# noinspection PyPep8Naming,PyShadowingNames
class scase(object):
- """A case that will ``chan.send(value)`` when the channel is able to send."""
+ """A case that will ``chan.send(value)``
+ when the channel is able to send."""
def __init__(self, chan, value):
self.chan = chan
self.value = value

0 comments on commit 707f365

Please sign in to comment.
Something went wrong with that request. Please try again.