Skip to content

Commit

Permalink
Do not expose imports.
Browse files Browse the repository at this point in the history
  • Loading branch information
rgalanakis committed Jul 11, 2014
1 parent 75c02dd commit a3d36ad
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 19 deletions.
10 changes: 5 additions & 5 deletions goless/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@
See http://goless.readthedocs.org/ for more documentation.
"""

import logging
import sys
import traceback
import logging as _logging
import sys as _sys
import traceback as _traceback

from .backends import current as _be, Deadlock, GolessException

Expand All @@ -37,7 +37,7 @@ def on_panic(etype, value, tb):
Called when there is an unhandled error in a goroutine.
By default, logs and exits the process.
"""
logging.critical(traceback.format_exception(etype, value, tb))
_logging.critical(_traceback.format_exception(etype, value, tb))
_be.propagate_exc(SystemExit, 1)


Expand All @@ -57,6 +57,6 @@ def safe_wrapped(f):
try:
f(*args, **kwargs)
except:
on_panic(*sys.exc_info())
on_panic(*_sys.exc_info())

_be.start(safe_wrapped, func)
18 changes: 9 additions & 9 deletions goless/backends.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import contextlib
import os
import platform
import sys
import contextlib as _contextlib
import os as _os
import platform as _platform
import sys as _sys


class GolessException(Exception):
Expand All @@ -13,7 +13,7 @@ def __init__(self, msg):
Exception.__init__(self, msg)


@contextlib.contextmanager
@_contextlib.contextmanager
def _as_deadlock(*errtypes):
try:
yield
Expand Down Expand Up @@ -97,7 +97,7 @@ def _make_gevent():
import gevent
import gevent.hub
import gevent.queue
deadlock_errtype = SystemError if os.name == 'nt' else gevent.hub.LoopExit
deadlock_errtype = SystemError if _os.name == 'nt' else gevent.hub.LoopExit

class Channel(gevent.queue.Channel):
def send(self, value):
Expand Down Expand Up @@ -142,7 +142,7 @@ def propagate_exc(self, errtype, *args):
and stackless (for Stackless Python or PyPy).
You are currently running %s.
See goless.backends.calculate_backend for more details about what backend
is chosen under what conditions.""" % sys.executable
is chosen under what conditions.""" % _sys.executable


class NoValidBackend(Exception):
Expand All @@ -168,7 +168,7 @@ def __call__(self, *args, **kwargs):
'gevent': _make_gevent
}

is_pypy = platform.python_implementation() == 'PyPy'
is_pypy = _platform.python_implementation() == 'PyPy'


def _calc_default(backends):
Expand Down Expand Up @@ -226,4 +226,4 @@ def calculate_backend(name_from_env, backends=None):
return NullBackend()


current = calculate_backend(os.getenv('GOLESS_BACKEND', ''))
current = calculate_backend(_os.getenv('GOLESS_BACKEND', ''))
10 changes: 5 additions & 5 deletions goless/channels.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import collections as _collections

from .backends import current as _be, GolessException as _GolessException
from .compat import range, maxint, PY3
from .compat import range as _range, maxint as _maxint, PY3 as _PY3


class ChannelClosed(_GolessException):
Expand Down Expand Up @@ -89,7 +89,7 @@ def _next(self):
except ChannelClosed:
raise StopIteration

if PY3:
if _PY3:
def __next__(self):
return self._next()
else:
Expand Down Expand Up @@ -181,9 +181,9 @@ def close(self):
# and raise a ChannelClosed error.
GoChannel.close(self)
balance = self.waiting_chan.balance
for _ in range(balance, 0):
for _ in _range(balance, 0):
self.waiting_chan.send(None)
for _ in range(balance):
for _ in _range(balance):
self.waiting_chan.receive()


Expand All @@ -209,7 +209,7 @@ class AsyncChannel(BufferedChannel):
"""

def __init__(self):
BufferedChannel.__init__(self, maxint)
BufferedChannel.__init__(self, _maxint)


def chan(size=0):
Expand Down

0 comments on commit a3d36ad

Please sign in to comment.